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> 对象。

返回

如果参数等于参数,则为 。

返回值取决于HasValueValue比较的两个参数的属性。

返回值 说明
true 参数HasValue的属性n1n2属性n2ValuefalseHasValuen1true或属性以及参数的属性相等。
falseHasValue属性针对true一个参数和false另一个参数,或HasValuen2n1true参数的属性和属性,参数Value的属性不相等。
属性

适用于