StringComparer::Compare Method (Object^, Object^)
When overridden in a derived class, compares two objects and returns an indication of their relative sort order.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- x
-
Type:
System::Object^
An object to compare to y.
- y
-
Type:
System::Object^
An object to compare to x.
Return Value
Type: System::Int32A signed integer that indicates the relative values of x and y, as shown in the following table.
Value | Meaning |
|---|---|
Less than zero | x precedes y in the sort order. -or- x is null and y is not null. |
Zero | x is equal to y. -or- x and y are both null. |
Greater than zero | x follows y in the sort order. -or- y is null and x is not null. |
Implements
IComparer::Compare(Object^, Object^)| Exception | Condition |
|---|---|
| ArgumentException | Neither x nor y is a String object, and neither x nor y implements the IComparable interface. |
The StringComparer::Compare(String^, String^) method is slightly more efficient than the StringComparer::Compare(Object^, Object^) method because no conversion of the x and y arguments is needed to perform the comparison.
Available since 2.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0