Is there any way I can separate a List
into several separate lists of SomeObject
, using the item index as the delimiter of each s
Just putting in my two cents. If you wanted to "bucket" the list (visualize left to right), you could do the following:
public static List> Buckets(this List source, int numberOfBuckets)
{
List> result = new List>();
for (int i = 0; i < numberOfBuckets; i++)
{
result.Add(new List());
}
int count = 0;
while (count < source.Count())
{
var mod = count % numberOfBuckets;
result[mod].Add(source[count]);
count++;
}
return result;
}