I am attempting to split a list into a series of smaller lists.
My Problem: My function to split lists doesn\'t split them into lists of the correct
I find accepted answer (Serj-Tm) most robust, but I'd like to suggest a generic version.
public static List> splitList(List locations, int nSize = 30)
{
var list = new List>();
for (int i = 0; i < locations.Count; i += nSize)
{
list.Add(locations.GetRange(i, Math.Min(nSize, locations.Count - i)));
}
return list;
}