Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows Task Scheduler problem Pin
Pete O'Hanlon6-Sep-10 2:12
mvePete O'Hanlon6-Sep-10 2:12 
GeneralBSCS FINAL PROJECT Pin
HUSSNAIN TOUFIQ6-Sep-10 0:53
HUSSNAIN TOUFIQ6-Sep-10 0:53 
GeneralRe: BSCS FINAL PROJECT PinPopular
OriginalGriff6-Sep-10 0:57
mveOriginalGriff6-Sep-10 0:57 
GeneralRe: BSCS FINAL PROJECT Pin
dan!sh 6-Sep-10 0:58
professional dan!sh 6-Sep-10 0:58 
GeneralRe: BSCS FINAL PROJECT Pin
Eddy Vluggen6-Sep-10 1:14
professionalEddy Vluggen6-Sep-10 1:14 
GeneralRe: BSCS FINAL PROJECT PinPopular
J4amieC6-Sep-10 1:28
J4amieC6-Sep-10 1:28 
GeneralRe: BSCS FINAL PROJECT Pin
DaveyM696-Sep-10 1:35
professionalDaveyM696-Sep-10 1:35 
GeneralRe: BSCS FINAL PROJECT Pin
Smithers-Jones6-Sep-10 2:12
Smithers-Jones6-Sep-10 2:12 
GeneralRe: BSCS FINAL PROJECT PinPopular
Pete O'Hanlon6-Sep-10 2:25
mvePete O'Hanlon6-Sep-10 2:25 
GeneralRe: BSCS FINAL PROJECT Pin
Smithers-Jones6-Sep-10 2:31
Smithers-Jones6-Sep-10 2:31 
GeneralRe: BSCS FINAL PROJECT Pin
Dave Kreskowiak6-Sep-10 3:52
mveDave Kreskowiak6-Sep-10 3:52 
Generalzoo Pin
Luc Pattyn6-Sep-10 5:15
sitebuilderLuc Pattyn6-Sep-10 5:15 
GeneralRe: BSCS FINAL PROJECT Pin
DaveyM696-Sep-10 2:38
professionalDaveyM696-Sep-10 2:38 
GeneralRe: BSCS FINAL PROJECT Pin
Smithers-Jones6-Sep-10 2:39
Smithers-Jones6-Sep-10 2:39 
GeneralRe: BSCS FINAL PROJECT Pin
Pete O'Hanlon6-Sep-10 2:41
mvePete O'Hanlon6-Sep-10 2:41 
GeneralRe: BSCS FINAL PROJECT Pin
DaveyM696-Sep-10 3:05
professionalDaveyM696-Sep-10 3:05 
GeneralRe: BSCS FINAL PROJECT Pin
Pete O'Hanlon6-Sep-10 3:15
mvePete O'Hanlon6-Sep-10 3:15 
GeneralRe: BSCS FINAL PROJECT Pin
DaveyM696-Sep-10 4:19
professionalDaveyM696-Sep-10 4:19 
GeneralRe: BSCS FINAL PROJECT Pin
Mycroft Holmes6-Sep-10 22:51
professionalMycroft Holmes6-Sep-10 22:51 
QuestionCalendarExtender popup appearing when Enter key is pressed. Pin
dev_asp_shreshtha6-Sep-10 0:48
dev_asp_shreshtha6-Sep-10 0:48 
AnswerRe: CalendarExtender popup appearing when Enter key is pressed. Pin
dan!sh 6-Sep-10 0:59
professional dan!sh 6-Sep-10 0:59 
QuestionNeed help with co/contravariance and generic lists :s Pin
Lee Reid5-Sep-10 23:12
Lee Reid5-Sep-10 23:12 
AnswerRe: Need help with co/contravariance and generic lists :s Pin
Kubajzz5-Sep-10 23:50
Kubajzz5-Sep-10 23:50 
GeneralRe: Need help with co/contravariance and generic lists :s [modified] Pin
Lee Reid6-Sep-10 0:41
Lee Reid6-Sep-10 0:41 
GeneralRe: Need help with co/contravariance and generic lists :s Pin
Kubajzz6-Sep-10 1:06
Kubajzz6-Sep-10 1:06 
Lee Reid wrote:
My project has several deriving classes, and values being entirely 'readonly' defeats the purpose of the whole class


I thought you only needed the complete list for iterating through all lists, thus a read-only iterator (such as IEnumerator) could be enough.

IEnumerable(T) can be implemented in a very clean way without the need of any "special programming".
See the following example:

C#
class A {}

class B : A {}

class C : A {}

class MyClass {
  private List<B> listB;
  private List<C> listC;

  public MyClass() {
    // Initialize lists...
  }

  public IEnumerable<A> GetAllItems() {
    // Get each list in this class as IEnumerable<A>
    IEnumerable<A> b = listB;
    IEnumerable<A> c = listC;

    return b.Concat(c);
  }
}


Yes, it is this simple. Note that the GetAllItems method could easily be 1-line long. You can implement some logic to get all the lists in the current class as an array of IEnumerable<A> for easy overriding, it's not more than 1 or 2 very short methods... I don't think this is messy, nor does it require any "special programming" and I highly doubt there is easier and simpler solution.

The one and only question is: does IEnumerable provide enough functionality for your application?

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.