C#数据分组

 1 static List<List<T>> DataPartial<T>(List<T> targetList, int count)
 2         {
 3             List<List<T>> target = new List<List<T>>();
 4             for (int i = 0; i < targetList.Count; i = i + count)
 5             {
 6                 List<T> temp = new List<T>();
 7                 for (int w = i; w < i + count; w++)
 8                 {
 9                     if (w == targetList.Count)
10                         break;
11                     else
12                         temp.Add(targetList[w]);
13                 }
14                 target.Add(temp);
15             }
16             return target;
17         }

 

posted @ 2018-07-31 10:10  屋檐不懂雨  阅读(1882)  评论(0编辑  收藏  举报