C# how to divide a list every 4 count Code Example
c# how to divide a list every 4 count
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;
}