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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.