System.StringComparer.Compare Method

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

Syntax

public abstract int Compare (string x, string y)

Parameters

x
A string to compare to y.
y
A string to compare to x.

Returns

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

Less than zero

x is less than y.

-or-

x is null.

Zero

x is equal to y.

Greater than zero

x is greater than y.

-or-

y is null.

Remarks

The StringComparer.Compare(string, string) method is more efficient than the StringComparer.Compare(object, object) method because the x and y parameters do not have to be unboxed to perform the comparison.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0