Defines a generalized comparison method that a value type or class implements to create a type-specific comparison method for ordering instances.
See Also: IComparable<T> Members
- Documentation for this section has not yet been entered.
This interface is implemented by types whose values can be ordered, primarily for sorting. For example, one number can be larger than a second number, and one string can appear in alphabetical order before another. A value type or class implements the IComparable`1.CompareTo(`0) method to create a type-specific comparison method suitable for purposes such as sorting.
The IComparable`1 interface defines the IComparable`1.CompareTo(`0) method, which determines the sort order of instances of the implementing type. The IEquatable`1 interface defines the IEquatable`1.Equals(`0) method, which determines the equality of instances of the implementing type.
|Less than zero||
This object is less than the object specified by the IComparable`1.CompareTo(`0) method.
This object is equal to the method parameter.
|Greater than zero||
This object is greater than the method parameter.
The IComparable`1 interface provides a strongly typed comparison method for ordering members of a generic collection object. Because of this, it is usually not called directly from developer code. Instead, it is called automatically by methods such as List`1.Sort and SortedList`2.Add(`0, `1).