Relative Ordering with IComparable and CompareTo

Someone asked a question on StackOverflow about the difference between the int CompareTo method and an ordinary If condition. As it turns out, the poster’s if statement is exactly how Int32 implements CompareTo. The IComparable and IComparable<T> interfaces each have only a single method, which can be used to compare two objects for the purpose of determining how they should be ordered relative to one another. // IComparable<T> - Compares the current object with another object of the same type. int CompareTo(T other); // IComparable - Compares the current object with another object. int »