EDIT: I split this to two questions:
- Iterate over two lists ending at the shorter one
- Iterate over several lists until the last element of the longest list has been reached
Assume I have two IEnumerable with many elements. Every IEnumerable has another type T.
IEnumerable<int> ints=getManyInts();
IEnumerable<string> strings=getSomeStrings();
What I want to do is to iterate over both lists, and get an item containing one int and one string for each step, until the end of the shortest list has been reached.
for(Item<int,string> item in Foo.Combine<int,string>(ints, strings))
{
int i=item.Val1;
string s=item.Val2;
}
You can also give me a hint how to do this in .NET 4.