我有这个收藏:
[bla1,blubb2,hello3,salve4,adios5,bye6,mucha7,arrividerci8,bonsoir9,hello10,bah11]
我想返回一个T的集合,其中T具有一个最多包含这3个字符串的List。
bla1, blubb2, hello3,
salve4, adios5, bye6
mucha7, arrividerci8,bonsoir9
hello10,bah11
这些不是4个对象,每个对象都具有最大列表。3项
看起来像您想要的:
List<List<string>> groups = inputList.Select((e, idx) => new { Item = e, Idx = idx })
.GroupBy(p => p.Idx / 3)
.Select(grp => grp.Select(p => p.Item).ToList())
.ToList();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句