开发者

Split a List of structs into sublists based on the stucts contents

开发者 https://www.devze.com 2022-12-21 01:46 出处:网络
I have a List that I need to split into sublists, one for each value of MyStruct.GroupingStrin开发者_运维知识库g.Can I do this via linq?somelist.ToLookup(x => x.GroupingString)

I have a List that I need to split into sublists, one for each value of MyStruct.GroupingStrin开发者_运维知识库g. Can I do this via linq?


somelist.ToLookup(x => x.GroupingString)


List<List<StructType>> groupings = list.GroupBy(x => x.GroupingString)
                                       .Select(x => x.ToList()).ToList();
0

精彩评论

暂无评论...
验证码 换一张
取 消