ToLookup with multiple keys

前端 未结 3 1787
囚心锁ツ
囚心锁ツ 2021-02-07 07:37

Is there a way to require multiple keys for the .ToLookup function provided by LINQ?

I will admit that this seems non-intuitive at first, and I\'m expecting

3条回答
  •  情书的邮戳
    2021-02-07 08:11

    Although not what you really want, but will do the job just fine:

    var r = set.ToLookup(x => new { x.StringProp, x.IntProp });
    var f = r[ new { StringProp = "a", IntProp = 1 } ].First();
    

提交回复
热议问题