Get groups of 4 elements from name value list using LINQ in C#

Posted by Kodefoo on Stack Overflow See other posts from Stack Overflow or by Kodefoo
Published on 2010-04-21T20:56:09Z Indexed on 2010/04/21 21:13 UTC
Read the original article Hit count: 109

Filed under:
|

I am wanting to loop through this list of name value pairs and grab them in groups of 4.

The data would be like:

value1 1
value2 1
value3 1
value4 1
value1 2
value2 2
value3 2
value4 2

and it would group it as 1 list that contains

value1 1
value2 1
value3 1
value4 1

and another list that contains

value1 2
value2 2
value3 2
value4 2

I know this can be done easily with a for loop, but I am wondering if there is a good way to do it with LINQ.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ