I've implemented a class that overloads the ==
and !=
operators.
This seems to work fine; however, I get the warning 'type' defines operator == or operator != but does not override Object.Equals(object o)
.
Okay, so I implemented Equals. But now I get the warning 'type' defines operator == or operator != but does not override Object.GetHashCode()
.
Does this end at some point? Or have I wandered into a never-ending trail of requirements just because I want to overload ==
and !=
?
Equals
, you need to overrideGetHashCode
as well, as it will check equality based on a hash function. – Plaster