When overloading some arithmetic operator overloads, it is very important to make sure that all related operators and methods are consistent in
their implementation.
The following guidelines should be followed:
- When providing
operator ==, !=
you should also provide Equals(Object)
and GetHashCode()
.
- When providing
operator +, -, *, / or %
you should also provide operator ==
, respecting the previous guideline.
This rule raises an issue when any of these guidelines are not followed on a publicly-visible class or struct (public
,
protected
or protected internal
).