C# Linq intersect/except with one part of object

后端 未结 7 986
终归单人心
终归单人心 2020-11-29 07:16

I\'ve got a class:

class ThisClass
{
  private string a {get; set;}
  private string b {get; set;}
}

I would like to use the Intersect and

7条回答
  •  迷失自我
    2020-11-29 07:58

    Maybe

    // returns list of intersecting property 'a' values
    foo.Select(f => f.a).Intersect(bar.Select(b => b.a));
    

    BTW property a should be public.

提交回复
热议问题