I have 3 sets in Linq, like this:
struct Index
{
string code;
int indexValue;
}
List<Index> reviews
List<Index> products
List<Index> pages
These lists have different code.
I want to merge these sets as following:
- Take the first in reviews
- Take the first in products
- Take the first in pages
- Take the second in reviews
-… and so on, note that these lists are not same-size.
How can I do this in Linq?
EDIT: Wait, is there a change to do this without .NET 4.0?
Thank you very much
You could use
Zipto do your bidding.Edit:
For .NET 3.5, it’s possible to implement
Zipquite easily: but there are a few gotcha s. Jon Skeet has a great post series on how to implement LINQ to objects operators (for educational purposes), including this post, onZip. The source code of the whole series, edulinq, can be found on Google Code.