The IComparable interface defines a generalized type-specific comparison method that a value type or class implements to order or sort its instances. The IComparable is implemented by types whose values can be ordered or sorted. The interface requires the CompareTo method to be implemented.
What is use of IComparable in C#?
Use the IComparable Interface in C# to sort elements. It is also used to compare the current instance with another object of same type. It provides you with a method of comparing two objects of a particular type. Remember, while implementing the IComparable interface, CompareTo() method should also be implemented.
What is the difference between comparable and IComparer?
IComparable has a method named as CompareTo & has only 1 parameter. Because it compares the current object with the next object which is coming as a parameter. Hence current object CompareTo next object. But IComparer has 2 parameters because we are going to pass both of the objects as arguments.