.ToLookup<TSource, TKey>
returns an ILookup<TKey, TSource>
. ILookup<TKey, TSource>
also implements interface IEnumerable<IGrouping<TKey, TSource>>
.
.GroupBy<TSource, TKey>
returns an IEnumerable<IGrouping<Tkey, TSource>>
.
ILookup has the handy indexer property, so it can be used in a dictionary-like (or lookup-like) manner, whereas GroupBy can't. GroupBy without the indexer is a pain to work with; pretty much the only way you can then reference the return object is by looping through it (or using another LINQ-extension method). In other words, any case that GroupBy works, ToLookup will work as well.
All this leaves me with the question why would I ever bother with GroupBy? Why should it exist?