开发者

ILookup versus IGrouping [duplicate]

开发者 https://www.devze.com 2023-01-14 18:08 出处:网络
This question already has answers here: ILookup<TKey, TVal> vs. IGrouping<TKey, TVal> (3 answers)
This question already has answers here: ILookup<TKey, TVal> vs. IGrouping<TKey, TVal> (3 answers) Closed 9 years ago.

ILookup and IGrouping are pretty similar Linq interfaces. Both bound a key to a list of values.

The quest开发者_StackOverflowion is what differs these both interface.

Does anyone have an example what you can do with one type that you are not able to todo with the other one?

When should you use "group by" and when "to lookup"?


You should call ToLookup if you need to lookup values by key, but you don't need ordering.

You should call GroupBy if you just need to loop through the groups.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号