Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

StringComparer.Compare Method (String, String)

 

When overridden in a derived class, compares two strings and returns an indication of their relative sort order.

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

public abstract int Compare(
	string x,
	string y
)

Parameters

x
Type: System.String

A string to compare to y.

y
Type: System.String

A string to compare to x.

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

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.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft