Vector.Equality(Vector, Vector) 运算符

定义

比较两个向量是否相等。

public:
 static bool operator ==(System::Windows::Vector vector1, System::Windows::Vector vector2);
public static bool operator == (System.Windows.Vector vector1, System.Windows.Vector vector2);
static member ( = ) : System.Windows.Vector * System.Windows.Vector -> bool
Public Shared Operator == (vector1 As Vector, vector2 As Vector) As Boolean

参数

vector1
Vector

要比较的第一个向量。

vector2
Vector

要比较的第二个向量。

返回

Boolean

如果 vector1vector2XY 分量相等,则为 true;否则为 false

示例

以下示例演示如何使用此运算符 (==) 来检查两个 Vector 结构是否相等。

private Boolean overloadedEqualityOperatorExample()
{
    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(45, 70);

    // If the two vectors are equal, areEqual is True,
    // otherwise it is False. In this example it is False.
    Boolean areEqual = (vector1 == vector2);

    return areEqual;
}
Private Function overloadedEqualityOperatorExample() As Boolean
    Dim vector1 As New Vector(20, 30)
    Dim vector2 As New Vector(45, 70)

    ' If the two vectors are equal, areEqual is True,
    ' otherwise it is False. In this example it is False.
    Dim areEqual As Boolean = (vector1 = vector2)

    Return areEqual

End Function

注解

使用Double值描述向量XY属性。 由于在算术运算上执行算术运算时的值 Double 可能会丢失精度,因此逻辑上相等的两 Vector 个结构之间的比较可能会失败。

适用于

另请参阅