As the operator overloading (operator> and operator<) violates the rule Operator overloads have named alternates, the operator > and < require an alternative method Compare, however, since there can only be one Compare method, what should the signature of that method be?
for example, I have:
public static bool operator >(XXX lhs, XXX rhs)
and
public static bool operator <(XXX lhs, XXX rhs)
How to provide a compare method to behave the same as both greater to and less than operators?
Edit:
The int Compare() only returns positive (greater than), negative (less than) and 0 (equal), what about in my overloaded operator there is a >= operator, which means my Compare method should handle (greater to or equal to) sinario as well
What about there are >, < >= and <= four overloaded operators?
Return value:
lhs is less than rhs.
lhs equals rhs.
lhs is greater than rhs.
Examples:
Usage:
Implementing IComparable<T> is also a good idea.