Reputation: 6061
I have a List that I need to split into sublists, one for each value of MyStruct.GroupingString. Can I do this via linq?
Upvotes: 2
Views: 537
Reputation: 422046
List<List<StructType>> groupings = list.GroupBy(x => x.GroupingString)
.Select(x => x.ToList()).ToList();
Upvotes: 3