Complex.Equality(Complex, Complex) 运算符

定义

返回一个值,该值指示两个复数是否相等。Returns a value that indicates whether two complex numbers are equal.

public:
 static bool operator ==(System::Numerics::Complex left, System::Numerics::Complex right);
public static bool operator == (System.Numerics.Complex left, System.Numerics.Complex right);
static member ( = ) : System.Numerics.Complex * System.Numerics.Complex -> bool
Public Shared Operator == (left As Complex, right As Complex) As Boolean

参数

left
Complex

要比较的第一个复数。The first complex number to compare.

right
Complex

要比较的第二个复数。The second complex number to compare.

返回

如果 trueleft 参数具有相同的值,则为 right;否则为 falsetrue if the left and right parameters have the same value; otherwise, false.

注解

Equality 方法定义 Complex 值的相等运算符的运算。The Equality method defines the operation of the equality operator for Complex values. 它可以实现如下所示的代码:It enables code such as the following:

Complex c1 = new Complex(12.6, 4.3);
Complex c2 = new Complex(11.1, 8.9);
if (c1 == c2) 
Dim c1 As New Complex(12.6, 4.3)
Dim c2 As New Complex(11.1, 8.9)
If c1 = c2 Then 

不支持自定义运算符的语言可以改为调用 Equals(Complex) 方法。Languages that do not support custom operators can call the Equals(Complex) method instead.

如果两个复数的实部相等并且其虚部相等,则这两个复数相等。Two complex numbers are equal if their real parts are equal and their imaginary parts are equal. Equality 方法等效于以下表达式:The Equality method is equivalent to the following expression:

return this.Real == value.Real && this.Imaginary == value.Imaginary;
Return Me.Real = value.Real AndAlso Me.Imaginary = value.Imaginary

请注意,由于精度差异,两个明显等效的复数可以视为不相等。Note that, because of differences in precision, two complex numbers that are apparently equivalent can be considered unequal. 有关详细信息和可能的解决方法,请参阅 Equals(Complex) 方法。For more information and a possible workaround, see the Equals(Complex) method.

此运算符的等效方法是 Complex.EqualsThe equivalent method for this operator is Complex.Equals

适用于