Possible Duplicate:
Split List into Sublists with LINQ
I'm looking for some way to split an enumerable into three enumerables using LINQ, such that each successive item in the input is in the next sublist in in the sequence. So input
{"a", "b", "c", "d", "e", "f", "g", "h"}
would result in
{"a", "d", "g"}, {"b", "e", "h"}, {"c", "f"}
I've done it this way but I'm sure there must be a way to express this more elegantly using LINQ.
var input = new List<string> {"a", "b", "c", "d", "e", "f", "g", "h"};
var list = new List<string>[3];
for (int i = 0; i < list.Length; i++)
list[i] = new List<string>();
int column = 0;
foreach (string letter in input)
{
list[column++].Add(letter);
if (column > 2) column = 0;
}