Mono Class Library: System.Collections.Comparer Overview | MembersSystem.Collections.Comparer.Compare Method |
Returns the sort order of two object instances. [Edit]
|
The return value is a negative number, zero, or a positive number reflecting the sort order of a as compared to b. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:
Value Condition A negative number a < b. Zero a == b. A positive number a > b. Note: A null reference is considered to compare less than any other non-null object, and equal to any other null reference, independent of the underlying Type of either object.[Edit]
Type Reason ArgumentException Both a and b are not null and do not implement the IComparable interface.
-or-
Both a and b are not null and are not assignment-compatible types.
[Edit]
The behavior of this method is as follows:
[Edit]
- If a implements the IComparable interface, returns a.CompareTo(b).
- If a does not implement the IComparable interface but b does, returns the negated result of b.CompareTo(a).
- If a and b both are not null and do not implement the IComparable interface, ArgumentException is thrown.
Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0