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

定義

表示兩個指定的 Nullable<T> 物件是否相等。

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

類型參數

T

n1n2 參數的基礎實值型別。

參數

n1
Nullable<T>

Nullable<T> 物件。

n2
Nullable<T>

Nullable<T> 物件。

傳回

如果 n1 參數等於 n2 參數,則為 true,否則為 false

傳回值取決於兩個比較參數的 HasValueValue 屬性。

傳回值 描述
true n1n2HasValue 屬性為 false,或 n1n2HasValue 屬性為 true,且參數的 Value 屬性皆相等。
false 某個參數的 HasValue 屬性為 true 且另一個參數的該屬性為 false,或 n1n2HasValue 屬性為 true,且參數的 Value 屬性皆不相等。
屬性

適用於