I've written a class deriving from IEqualityComparer<T>
which works great for the LINQ query I needed it for.
As I understand it, GetHashCode()
(fast) is called first, then Equals()
(slightly slower) if the hashcode is the same, for such operations.
However when using it for direct comparisons, manually, I'm using something like
return new MyIEqualityComparer().Equals(objA,objB);
Which forgoes the faster GetHashCode()
equality check. Is there a way of comparing objA
to objB
which doesn't automatically skip the faster GetHashCode()
check?
I guess I was hoping objA.Equals()
would have an overload that accepted an argument derived from IEqualityComparer<T>
.