I am trying to implement a simple IEqulityComparer for use with LINQ collections. I wrote the following code, which boils down to its simplest form for discussion ...
Public Structure bob
Dim SiteID As Integer
Dim fred As String
End Structure
Public Class insCompare
Implements System.Collections.Generic.IEqualityComparer(Of bob)
Public Function Equals(ByVal x As bob, ByVal y As bob) As Boolean
Return IIf(x.SiteID = y.SiteID, True, False)
End Function
Public Function GetHashCode(ByVal x As bob) As Integer
Return x.SiteID.GetHashCode()
End Function
End Class
The problem is that both functions throw a warning to the compiler “getHashCode function” (or “Equals”) obscures the overridden method in the base class “Object”. To override a base class method, this method must be declared "Overrides".
However, if I declare them as overrides, I get the error "GetHashCode function" cannot be declared Overrides, because it does not override the function in the base class. "
"", "getHashCode", , .
, - - - , ?