共用方式為


Point.Inequality(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 op_Inequality : System.Windows.Point * System.Windows.Point -> bool
Public Shared Operator != (point1 As Point, point2 As Point) As Boolean

參數

point1
Point

要比較的第一個點。

point2
Point

要比較的第二個點。

傳回

Boolean

如果 point1point2 具有不同的 XY 座標,則為 true;如果 point1point2 具有相同的 XY 座標,則為 false

範例

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

private Boolean overloadedInequalityOperatorExample()
{
    Point point1 = new Point(20, 30);
    Point point2 = new Point(45, 70);

    // Check whether the two Points are not equal, using the overloaded 
    // inequality operator.
    // areNotEqual is True.
    Boolean areNotEqual = (point1 != point2);

    return areNotEqual;
}
Private Function overloadedInequalityOperatorExample() As Boolean
    Dim point1 As New Point(20, 30)
    Dim point2 As New Point(45, 70)

    ' Check whether the two Points are not equal, using the overloaded 
    ' inequality operator.
    ' areNotEqual is True.
    Dim areNotEqual As Boolean = (point1 <> point2)

    Return areNotEqual

End Function

備註

點和 X Y 座標會使用 Double 值來描述。 因為 Double 值在操作時可能會失去精確度,因此邏輯上相等的兩 Point 個值之間的比較可能會失敗。

適用於