Reputation: 180
I don't understand why does the Equals method take (T x, T y). Don't you already have one instance to compare to when you invoke the method on an instance? Same for GetHashCode - why does it need an object instance as a parameter if I'm already invoking it on an existing instance?
What would happen if I invoke a.GetHashCode(b)? Which one is used?
Upvotes: 0
Views: 133
Reputation: 70671
The IEqualityComparer<T>
interface is for a comparer object. So, no...you would not already have one instance as part of the implementation.
You may be thinking of IEquatable<T>
, where it's implemented by the type of object being compared.
Upvotes: 5