共用方式為


Nullable.Compare<T>(Nullable<T>, Nullable<T>) 方法

定義

比較兩個 Nullable<T> 物件的相對值。

public:
generic <typename T>
 where T : value class static int Compare(Nullable<T> n1, Nullable<T> n2);
public static int Compare<T> (T? n1, T? n2) where T : struct;
[System.Runtime.InteropServices.ComVisible(true)]
public static int Compare<T> (T? n1, T? n2) where T : struct;
[System.Runtime.InteropServices.ComVisible(false)]
public static int Compare<T> (T? n1, T? n2) where T : struct;
static member Compare : Nullable<'T (requires 'T : struct)> * Nullable<'T (requires 'T : struct)> -> int (requires 'T : struct)
[<System.Runtime.InteropServices.ComVisible(true)>]
static member Compare : Nullable<'T (requires 'T : struct)> * Nullable<'T (requires 'T : struct)> -> int (requires 'T : struct)
[<System.Runtime.InteropServices.ComVisible(false)>]
static member Compare : Nullable<'T (requires 'T : struct)> * Nullable<'T (requires 'T : struct)> -> int (requires 'T : struct)
Public Shared Function Compare(Of T As Structure) (n1 As Nullable(Of T), n2 As Nullable(Of T)) As Integer

類型參數

T

n1n2 參數的基礎實值型別。

參數

n1
Nullable<T>

Nullable<T> 物件。

n2
Nullable<T>

Nullable<T> 物件。

傳回

Int32

整數,表示 n1n2 參數的相對值。

傳回值 描述
小於零 n1HasValue 屬性為 false,且 n2HasValue 屬性為 true,或 n1n2HasValue 屬性為 true,且 n1Value 屬性值小於 n2Value 屬性值。
n1n2HasValue 屬性為 false,或 n1n2HasValue 屬性為 true,且 n1Value 屬性值等於 n2Value 屬性值。
大於零 n1HasValue 屬性為 true,且 n2HasValue 屬性為 false,或 n1n2HasValue 屬性為 true,且 n1Value 屬性值大於 n2Value 屬性值。
屬性

適用於