1

i have this list in C#:

enter image description here

and i wanna divide it to 4 list like this :

enter image description here

how can i do this with Linq?

Rowland Shaw
  • 37,138
  • 14
  • 95
  • 164
Ali7091
  • 734
  • 1
  • 12
  • 19

1 Answers1

2

You want to group by Field1, so use Enumerable.GroupBy:

var field1GroupLists = mainList
    .GroupBy(x => x.Field1)
    .Select(group => group.ToList())
    .ToList();
Tim Schmelter
  • 429,027
  • 67
  • 649
  • 891