How to get values from IGrouping

I have a question about IGrouping and the Select() method.

Let’s say I’ve got an IEnumerable<IGrouping<int, smth>> in this way:

var groups = list.GroupBy(x => x.ID);

where list is a List<smth>.

And now I need to pass values of each IGrouping to another list in some way:

foreach (var v in structure)
{
    v.ListOfSmth = groups.Select(...); // <- ???
}

Can anybody suggest how to get the values (List<smth>) from an IGrouping<int, smth> in such a context?

8 Answers
8

Leave a Comment