Export (0) Print
Expand All

StringComparer.IComparer.Compare Method

.NET Framework 4.5

Compares two objects and returns a value that indicates whether one is less than, equal to, or greater than the other.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

int IComparer.Compare(
	Object x,
	Object y
)

Parameters

x
Type: System.Object

The first object to compare.

y
Type: System.Object

The second object to compare.

Return Value

Type: System.Int32
A signed integer that indicates the relative values of x and y, as shown in the following table.

Value

Meaning

Less than zero

x is less than y.

Zero

x equals y.

Greater than zero

x is greater than y.

Implements

IComparer.Compare(Object, Object)

ExceptionCondition
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.

This member is an explicit interface implementation. It can be used only when the StringComparer instance is cast to an IComparer interface.

Comparing null with any type is allowed and does not generate an exception. When sorting, null is considered to be less than any object.

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8
Show:
© 2014 Microsoft