I fail to remove duplicates from my List. What am I doing wrong?
Dim Contacts As New List(Of Person)
...
' remove duplicates '
Contacts = Contacts.Distinct(New PersonEqualityComparer).ToList
my equality comparer:
Public Class PersonEqualityComparer
Implements IEqualityComparer(Of Person)
Public Function Equals1(ByVal x As Person, ByVal y As Person) As Boolean Implements System.Collections.Generic.IEqualityComparer(Of Person).Equals
Return String.Equals(x.EmailAddress, y.EmailAddress, StringComparison.CurrentCultureIgnoreCase) AndAlso _
String.Equals(x.GivenName, y.GivenName, StringComparison.CurrentCultureIgnoreCase) AndAlso _
String.Equals(x.Surname, y.Surname, StringComparison.CurrentCultureIgnoreCase)
End Function
Public Function GetHashCode1(ByVal obj As Person) As Integer Implements System.Collections.Generic.IEqualityComparer(Of Person).GetHashCode
Return obj.GetHashCode
End Function
End Class