ILookup vs. IGrouping

Yes, all of those are correct. And ILookup<TKey, TValue> also extends IEnumerable<IGrouping<TKey, TValue>> so you can iterate over all the key/collection pairs as well as (or instead of) just looking up particular keys. I basically think of ILookup<TKey,TValue> as being like IDictionary<TKey, IEnumerable<TValue>>. Bear in mind that ToLookup is a “do it now” operation (immediate … Read more

How to get values from IGrouping

Since IGrouping<TKey, TElement> implements IEnumerable<TElement>, you can use SelectMany to put all the IEnumerables back into one IEnumerable all together: List<smth> list = new List<smth>(); IEnumerable<IGrouping<int, smth>> groups = list.GroupBy(x => x.id); IEnumerable<smth> smths = groups.SelectMany(group => group); List<smth> newList = smths.ToList(); Here’s an example that builds/runs: https://dotnetfiddle.net/DyuaaP Video commentary of this solution: https://youtu.be/6BsU1n1KTdo