Freigeben über


LanguagePrimitives.Compare Method

Definition

Overloads

Compare(Object, Object)

Compare first and second, converting second to the type of the first, if necessary.

Compare(Object, Object, Boolean)

Compare first and second, converting second to the type of the first, if necessary.

Compare(Object, Object, Boolean, IFormatProvider)

Compare first and second, converting second to the type of the first, if necessary.

Compare(Object, Object)

Compare first and second, converting second to the type of the first, if necessary.

public:
 static int Compare(System::Object ^ first, System::Object ^ second);
public:
 static int Compare(Platform::Object ^ first, Platform::Object ^ second);
 static int Compare(winrt::Windows::Foundation::IInspectable const & first, winrt::Windows::Foundation::IInspectable const & second);
public static int Compare (object first, object second);
static member Compare : obj * obj -> int
Public Shared Function Compare (first As Object, second As Object) As Integer

Parameters

first
Object

First comparison value.

second
Object

Second comparison value.

Returns

Less than zero if first is smaller than second, more than zero if it is greater or zero if they are the same.

Exceptions

first does not implement IComparable or second cannot be converted to the type of first.

Applies to

Compare(Object, Object, Boolean)

Compare first and second, converting second to the type of the first, if necessary.

public:
 static int Compare(System::Object ^ first, System::Object ^ second, bool ignoreCase);
public:
 static int Compare(Platform::Object ^ first, Platform::Object ^ second, bool ignoreCase);
 static int Compare(winrt::Windows::Foundation::IInspectable const & first, winrt::Windows::Foundation::IInspectable const & second, bool ignoreCase);
public static int Compare (object first, object second, bool ignoreCase);
static member Compare : obj * obj * bool -> int
Public Shared Function Compare (first As Object, second As Object, ignoreCase As Boolean) As Integer

Parameters

first
Object

First comparison value.

second
Object

Second comparison value.

ignoreCase
Boolean

Used if both values are strings.

Returns

Less than zero if first is smaller than second, more than zero if it is greater or zero if they are the same.

Exceptions

first does not implement IComparable or second cannot be converted to the type of first.

Applies to

Compare(Object, Object, Boolean, IFormatProvider)

Compare first and second, converting second to the type of the first, if necessary.

public:
 static int Compare(System::Object ^ first, System::Object ^ second, bool ignoreCase, IFormatProvider ^ formatProvider);
public static int Compare (object first, object second, bool ignoreCase, IFormatProvider formatProvider);
static member Compare : obj * obj * bool * IFormatProvider -> int
Public Shared Function Compare (first As Object, second As Object, ignoreCase As Boolean, formatProvider As IFormatProvider) As Integer

Parameters

first
Object

First comparison value.

second
Object

Second comparison value.

ignoreCase
Boolean

Used if both values are strings.

formatProvider
IFormatProvider

Used in type conversions and if both values are strings.

Returns

Less than zero if first is smaller than second, more than zero if it is greater or zero if they are the same.

Exceptions

first does not implement IComparable or second cannot be converted to the type of first.

Applies to