Double.Equality(Double, Double) 運算子

定義

傳回值,這個值表示兩個指定的 Double 值是否相等。Returns a value that indicates whether two specified Double values are equal.

public:
 static bool operator ==(double left, double right);
public static bool operator == (double left, double right);
static member ( = ) : double * double -> bool
Public Shared Operator == (left As Double, right As Double) As Boolean

參數

left
Double

要比較的第一個值。The first value to compare.

right
Double

要比較的第二個值。The second value to compare.

傳回

如果 leftright 相等,則為 true;否則為 falsetrue if left and right are equal; otherwise, false.

備註

Equality 方法會定義 Double 值的等號比較運算子。The Equality method defines the equality operator for Double values.

如果使用等號比較運算子測試兩個 Double.NaN 值是否相等,則結果會是 false;兩個 Double.NaN 值不會視為相等。If two Double.NaN values are tested for equality by using the equality operator, the result is false; two Double.NaN values are not considered equal. 如果藉由呼叫 Equals 方法來測試是否相等,則會 true結果。If they are tested for equality by calling the Equals method, the result is true. 當您想要判斷 Double 的值是否不是數位(NaN)時,替代方式是呼叫 IsNaN 方法。When you want to determine whether the value of a Double is not a number (NaN), an alternative is to call the IsNaN method.

適用於