public interface IComparer
|
The default implementation of this interface is the Comparer class.
Comparison procedures use the Thread.CurrentCulture of the current thread unless otherwise specified. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the System.Globalization namespace and the conceptual topic at MSDN: designingglobalapplications.
Compare | Compares two objects and returns a value indicating whether one is less than, equal to or greater than the other. |
x
y
Value | Condition |
---|---|
Less than zero | is less than . |
Zero | equals . |
Greater than zero | is greater than . |
Exception Type | Condition |
---|---|
ArgumentException | Neither x nor y implements the IComparable interface. -or- x and y are of different types and neither one can handle comparisons with the other. |
Comparing null with any type is allowed and does not generate an exception when using IComparable. When sorting, null is considered to be less than any other object.
Comparison procedures use the Thread.CurrentCulture of the current thread unless otherwise specified. String comparisons might have different results depending on the culture. For more information on culture-specific comparisons, see the System.Globalization namespace and the conceptual topic at MSDN: designingglobalapplications.