c# 拆分list
/// <summary> /// 拆分list /// </summary> /// <typeparam name="T"></typeparam> /// <param name="list">原始list</param> /// <param name="blockSize">拆分长度</param> /// <returns></returns> public List<List<T>> GetBlockList<T>(List<T> list, int blockSize = 500) { List<List<T>> result = new List<List<T>>(); var temp = new List<T>(); for (int i = 0; i < list.Count; i++) { temp.Add(list[i]); if ((i + 1) % blockSize == 0 && i > 0) { result.Add(temp); temp = new List<T>(); } if (i == list.Count - 1) { result.Add(temp); } } return result; }