how does except method work in linq

后端 未结 5 2194
梦毁少年i
梦毁少年i 2020-12-05 20:45

I have the classes:

class SomeClass
{
   public string Name{get;set;}
   public int SomeInt{get;set;}
}


class SomeComparison: IEqualityComparer

        
5条回答
  •  清歌不尽
    2020-12-05 20:55

    This is the way i think about it.

    IEnumerable Except(IEnumerable a,IEnumerable b)
    {
        return a.Where(x => !b.Contains(x)).Distinct();
    }
    

提交回复
热议问题