Accepted answer

First, you don't need to implement the IEqualityComparer(Of T) interface; you would normally implement that in another class if you wanted to provide multiple types of equality for the same class.

Second, you'll need to override the GetHashCode and Equals(Object) methods:

Partial Public Class CustomerData
   Implements IEquatable(Of CustomerData)

   Public Override Function GetHashCode() As Integer
      Return CustomerID.GetHashCode()
   End Function

   Public Override Function Equals(ByVal obj As Object)
      Return Equals(TryCast(obj, CustomerData))
   End Function

   Public Overloads Function Equals(other As CustomerData) As Boolean Implements IEquatable(Of ToolData.CustomerData).Equals
      If other Is Nothing Then
         Return False
         Return Me.CustomerID = other.CustomerID
      End If
   End Function


Here's a blog post which explains why:

Related Articles