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
參數
傳回
true若 XY 和 point1point2 的座標相等;否則 。 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 值之間比較可能會失敗。