The C# compiler requires that whenever a custom type defines operator ==
, it must also define !=
(see here).
Why?
I\'m curious to k
If you overload == for your custom type, and not != then it will be handled by the != operator for object != object since everything is derived from object, and this would be much different than CustomType != CustomType.
Also the language creators probably wanted it this way to allow the most most flexibility for coders, and also so that they are not making assumptions about what you intend to do.