Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
IComparable is designed to establish an order relationship between objects that implement this interface, or, roughly speaking, to sort. Those. when for two given objects A and B you can argue that A < B OR A == B OR A > B.
IEquatable is designed to establish an equality relationship. When for two given objects A and B you can argue that A == B or A != B.
Not for all data types you want and can set an order relation, while for most types with value-semantics you want have an equality/inequality relation. This is such a common and necessary thing that C# entries will automatically implement IEquatable for you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question