Split Large List in mutiple lists

Below function helps to split existing list into multiple, set nSize to any number and it will create lists of same size.

This can be very useful for parallel LINQ. 
  1. public static List<List<Class Name>> splitList(List<Class Name> locations, int nSize = 20000)  
  2. {  
  3.   
  4. var list = new List<List<Class Name>>();  
  5.   
  6. for (int i = 0; i < locations.Count; i += nSize)  
  7.   
  8. {  
  9.   
  10. list.Add(locations.GetRange(i, Math.Min(nSize, locations.Count - i)));  
  11.   
  12. }  
  13.   
  14. return list;  
  15.