How to remove duplicates from collection using IEqualityComparer, LinQ Distinct

前端 未结 6 1855
梦如初夏
梦如初夏 2020-12-05 04:36

I am unable to remove the duplicates from collection , i have implemented IEqualityComparer for the class Employee still i am not getting the output

static v         


        
6条回答
  •  清歌不尽
    2020-12-05 05:06

    Forget IEqualityComparer and just use Linq directly:

    EmployeeCollection.GroupBy(x => new{x.fName, x.lName}).Select(g => g.First());
    

提交回复
热议问题