joining IEnumerables together

  • Thread starter Thread starter cody
  • Start date Start date
C

cody

Hi, I have multiple Collections which I want to iterate over *without*
copying alle my collections into one.

If there is no method to do this I propose a new Class Enumerate which
should provide something like that: IEnumerable Join(IEnumerable
a,IEnumerable b)
 
cody said:
Hi, I have multiple Collections which I want to iterate over *without*
copying alle my collections into one.

If there is no method to do this I propose a new Class Enumerate which
should provide something like that: IEnumerable Join(IEnumerable
a,IEnumerable b)

That's very easy to write - I suggest you try it and see how useful it
is for you.
 
Yes writing that kind of functionality is not a problem but it would be
great if the framework would provide such a thing, just because I don't like
always having to reinvent the wheel.
 
In 2.0 this becomes trivial:

public IEnumerable<T> JoinTwoEnumerators(IEnumerable<T> first,
IEnumerable<T> second)
{
foreach (T t in first)
{
yield return t;
}

foreach (T t in second)
{
yield return t;
}
}


cody said:
Yes writing that kind of functionality is not a problem but it would be
great if the framework would provide such a thing, just because I don't
like always having to reinvent the wheel.
 
public IEnumerable<T> JoinEnumerators(params IEnumerable<T>[] enums) {
foreach ( IEnumerator enum in enums )
foreach ( T t in enum )
yield return t;
}
 
Back
Top