Point.Equality(Point, Point) 運算子
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
比較兩個 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
和 point2
的 X 和 Y 座標相等則為 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 個值之間的比較可能會失敗。