Questions tagged «ilookup»

3
ILookup <TKey,TVal>与IGrouping <TKey,TVal>
我一直有麻烦之间阐明的差异ILookup&lt;TKey, TVal&gt;和IGrouping&lt;TKey, TVal&gt;,并很好奇,如果我理解正确了。LINQ通过产生IGrouping项目序列使问题更加复杂,同时还提供了ToLookup扩展方法。因此,直到我仔细观察之前,它们似乎都是一样的。 var q1 = from n in N group n by n.MyKey into g select g; // q1 is IEnumerable&lt;IGrouping&lt;TKey, TVal&gt;&gt; 等效于: var q2 = N.GroupBy(n =&gt; n.MyKey, n =&gt; n); // q2 is IEnumerable&lt;IGrouping&lt;TKey, TVal&gt;&gt; 看起来很像: var q3 = N.ToLookup(n =&gt; n.MyKey, n =&gt; n); // q3 …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.