There are two things to consider here.
- What is documented
- What is implemented
The actual implementation might currently always return -1, 0, or 1, never anything else. Note that I have not verified this.
However, the documentation specifies that it is legal to use negative values, and positive values, not just -1 and +1.
This means that for you to write robust code using .CompareTo
, you need to handle negative and positive values, not just -1 and +1.
Note that this does not mean that you cannot return -1 and +1 from your own implementations of CompareTo
, but you need to be prepared for any other values as well.
For simplicity, in some cases, an implementation might just return the result of subtracting one value from another, and thus you will get something that isn't -1 or +1.