Export (0) Print
Expand All

IComparer.Compare Method

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

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

int Compare (
	T x,
	T y
)
int Compare (
	T x, 
	T y
)
function Compare (
	x : T, 
	y : T
) : int
Not applicable.

Parameters

x

The first object to compare.

y

The second object to compare.

Return Value

Value

Condition

Less than zero

x is less than y.

Zero

x equals y.

Greater than zero

x is greater than y.

Implement this method to provide a customized sort order comparison for type T.

Comparing a null reference (Nothing in Visual Basic) with any reference type is allowed and does not generate an exception. A null reference is considered to be less than any reference that is not null.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft