共用方式為


Point.Equality(Point, Point) 運算子

定義

比較兩個 Point 結構是否相等。

public:
 static bool operator ==(System::Windows::Point point1, System::Windows::Point point2);
public static bool operator == (System.Windows.Point point1, System.Windows.Point point2);
static member ( = ) : System.Windows.Point * System.Windows.Point -> bool
Public Shared Operator == (point1 As Point, point2 As Point) As Boolean

參數

point1
Point

要比較的第一個 Point 結構。

point2
Point

要比較的第二個 Point 結構。

傳回

Boolean

如果 point1point2XY 座標相等則為 true,否則為 false

範例

下列範例示範如何使用多載的 (==) 運算子檢查兩 Point 個結構是否相等。

private Boolean overloadedEqualityOperatorExample()
{
    Point point1 = new Point(10, 5);
    Point point2 = new Point(15, 40);

    // Check if two Points are equal using the overloaded equality operator.
    // areEqual is False.
    Boolean areEqual = (point1 == point2);

    return areEqual;
}
Private Function overloadedEqualityOperatorExample() As Boolean
    Dim point1 As New Point(10, 5)
    Dim point2 As New Point(15, 40)

    ' Check if two Points are equal using the overloaded equality operator.
    ' areEqual is False.
    Dim areEqual As Boolean = (point1 = point2)

    Return areEqual

End Function

備註

點的座標會使用 Double 值來描述。 由於 的值 Double 在算數運算上執行時可能會失去有效位數,因此在邏輯上相等的兩 Point 個值之間的比較可能會失敗。

適用於

另請參閱