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 属性为 falsen2HasValue 属性为 true,或者 n1n2HasValue 属性为 truen1Value 属性值小于 n2Value 属性值。
n1n2HasValue 属性为 false,或者 n1n2HasValue 属性为 truen1Value 属性值等于 n2Value 属性值。
大于零 n1HasValue 属性为 truen2HasValue 属性为 false,或者 n1n2HasValue 属性为 truen1Value 属性值大于 n2Value 属性值。
属性

适用于