Click here to Skip to main content
15,913,722 members
Home / Discussions / C#
   

C#

 
AnswerRe: Parse Excel Currency Cell Pin
DaveyM6915-Dec-11 13:33
professionalDaveyM6915-Dec-11 13:33 
AnswerRe: Parse Excel Currency Cell Pin
Richard MacCutchan15-Dec-11 22:26
mveRichard MacCutchan15-Dec-11 22:26 
QuestionHow to include child property of LINQ to SQL object? Pin
Goalie3515-Dec-11 11:04
Goalie3515-Dec-11 11:04 
AnswerRe: How to include child property of LINQ to SQL object? Pin
Mycroft Holmes15-Dec-11 18:48
professionalMycroft Holmes15-Dec-11 18:48 
QuestionCollections, plus collection of base type - concept Pin
DaveyM6915-Dec-11 9:16
professionalDaveyM6915-Dec-11 9:16 
AnswerRe: Collections, plus collection of base type - concept Pin
PIEBALDconsult15-Dec-11 9:34
mvePIEBALDconsult15-Dec-11 9:34 
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6915-Dec-11 9:47
professionalDaveyM6915-Dec-11 9:47 
GeneralRe: Collections, plus collection of base type - concept Pin
PIEBALDconsult15-Dec-11 10:40
mvePIEBALDconsult15-Dec-11 10:40 
Here's a little something I whipped up to experiment.

A base class, two derived classes, and a list for each derived class:

private class C
{
   public string Name { get ; private set ; }

   public C ( string Name ) { this.Name = Name ; }

   public override string ToString() { return ( this.Name ) ; }
}

private class A : C
{
   public A ( string Name ) : base ( Name ) {}
}

private class B : C
{
   public B ( string Name ) : base ( Name ) {}
}

private static System.Collections.Generic.List<A> alist = new System.Collections.Generic.List<A>() ;
private static System.Collections.Generic.List<B> blist = new System.Collections.Generic.List<B>() ;


An enumerator (or is it an iterator?) -- I think it would be in your base class and probably not take parameters:

private static System.Collections.Generic.IEnumerable<C>
All
(
  params System.Collections.Generic.IEnumerable<C>[] lists
)
{
  foreach ( System.Collections.Generic.IEnumerable<C> l in lists )
  {
    foreach ( C c in l )
    {
      yield return ( c ) ;
    }
  }

  yield break ;
}


Then I can call it:

foreach ( C c in All ( alist , blist ) )
{
  System.Console.WriteLine ( c ) ;
}


The code that does this could choose to cache the results if it needs to.
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6915-Dec-11 11:27
professionalDaveyM6915-Dec-11 11:27 
GeneralRe: Collections, plus collection of base type - concept Pin
PIEBALDconsult15-Dec-11 11:51
mvePIEBALDconsult15-Dec-11 11:51 
GeneralRe: Collections, plus collection of base type - concept Pin
Luc Pattyn15-Dec-11 19:55
sitebuilderLuc Pattyn15-Dec-11 19:55 
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6915-Dec-11 23:54
professionalDaveyM6915-Dec-11 23:54 
GeneralRe: Collections, plus collection of base type - concept Pin
BillWoodruff16-Dec-11 4:03
professionalBillWoodruff16-Dec-11 4:03 
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6916-Dec-11 14:20
professionalDaveyM6916-Dec-11 14:20 
GeneralRe: Collections, plus collection of base type - concept Pin
BillWoodruff16-Dec-11 18:19
professionalBillWoodruff16-Dec-11 18:19 
AnswerRe: executive summary Pin
Luc Pattyn17-Dec-11 2:23
sitebuilderLuc Pattyn17-Dec-11 2:23 
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6917-Dec-11 2:15
professionalDaveyM6917-Dec-11 2:15 
AnswerRe: Collections, plus collection of base type - concept Pin
Luc Pattyn17-Dec-11 2:32
sitebuilderLuc Pattyn17-Dec-11 2:32 
GeneralRe: Collections, plus collection of base type - concept Pin
Luc Pattyn17-Dec-11 2:42
sitebuilderLuc Pattyn17-Dec-11 2:42 
AnswerRe: Collections, plus collection of base type - concept Pin
Luc Pattyn17-Dec-11 2:48
sitebuilderLuc Pattyn17-Dec-11 2:48 
GeneralRe: Collections, plus collection of base type - concept Pin
DaveyM6917-Dec-11 3:10
professionalDaveyM6917-Dec-11 3:10 
AnswerRe: Collections, plus collection of base type - concept Pin
Luc Pattyn17-Dec-11 3:50
sitebuilderLuc Pattyn17-Dec-11 3:50 
AnswerRe: Collections, plus collection of base type - concept Pin
BillWoodruff16-Dec-11 20:48
professionalBillWoodruff16-Dec-11 20:48 
QuestionBoundColumns Not Working Pin
AmbiguousName15-Dec-11 6:45
AmbiguousName15-Dec-11 6:45 
AnswerRe: BoundColumns Not Working Pin
PIEBALDconsult15-Dec-11 7:02
mvePIEBALDconsult15-Dec-11 7:02 

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.