共用方式為


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

備註

向量的 XY 屬性會使用 Double 值來描述。 由於 的值 Double 可能會在算數運算上執行時失去精確度,因此邏輯上相等的兩 Vector 個結構之間的比較可能會失敗。

適用於

另請參閱