You can use a simple module to group the dictionary in parts:
int numberOfGroups = 4; int counter = 0; var result = dict.GroupBy(x => counter++ % numberOfGroups);
The module ( % ) makes GroupBy restriction a limited number in the range 0..3 (actually 0..numberOfGroups - 1 ). This will make the grouping for you.
The problem though with this is that it does not keep order. It does:
decimal numberOfGroups = 4; int counter = 0; int groupSize = Convert.ToInt32(Math.Ceiling(dict.Count / numberOfGroups)); var result = dict.GroupBy(x => counter++ / groupSize);
source share