You need to create an equalizer and use it in Union or Distinct :
Public Class MyComparer Implements IEqualityComparer(Of ICustomer) Public Overloads Function Equals(ByVal x As ICustomer, ByVal y As ICustomer) _ As Boolean Implements _ System.Collections.Generic.IEqualityComparer(Of ICustomer).Equals Return ((x.id = y.id) AndAlso (x.title = y.title)) End Function Public Overloads Function GetHashCode(ByVal obj As ICustomer) _ As Integer Implements _ System.Collections.Generic.IEqualityComparer(Of ICustomer).GetHashCode Return Me.GetHashCode() End Function End Class
Usage example:
Dim allMatch = shortNameMatch.Union(custNameMatch).Distinct(New MyComparer()) Dim allMatch = shortNameMatch.Union(custNameMatch, New MyComparer())
source share