How to remove duplicates from collection using IEqualityComparer, LinQ Distinct

前端 未结 6 1848
梦如初夏
梦如初夏 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 04:53

    public int GetHashCode(Employe obj)
    {
        return obj.GetHashCode();
    }
    

    For this method, return a hashcode of the properties that you are comparing for equality, instead of the object itself. Comparing the hashcode of the objects will always be false, so your list will never be filtered for duplicates.

提交回复
热议问题