C# List分组 分成固定数量一组数据

//分组  8个为一组 
List<List<string>> ArrayList = sArray.Select((x, i) => new { Index = i, Value = x })
.GroupBy(x => x.Index / 8)
.Select(x => x.Select(v => v.Value).ToList())
.ToList();

原文:https://www.cnblogs.com/TTonly/p/11863112.html

发现新方法 

安装 morelinq 包 里面封装大量常用linq方法

  var ArrayList = sArray.Batch(8);

 

posted @ 2023-03-21 01:05  Echo_xxx  阅读(375)  评论(0编辑  收藏  举报