Rect.Equals メソッド

定義

2 つの四角形が等しいかどうかを示します。

オーバーロード

Equals(Rect, Rect)

指定した四角形が等しいかどうかを示します。

Equals(Object)

指定したオブジェクトが現在の四角形と等しいかどうかを示します。

Equals(Rect)

指定した四角形が現在の四角形と等しいかどうかを示します。

Equals(Rect, Rect)

指定した四角形が等しいかどうかを示します。

public:
 static bool Equals(System::Windows::Rect rect1, System::Windows::Rect rect2);
public static bool Equals (System.Windows.Rect rect1, System.Windows.Rect rect2);
static member Equals : System.Windows.Rect * System.Windows.Rect -> bool
Public Shared Function Equals (rect1 As Rect, rect2 As Rect) As Boolean

パラメーター

rect1
Rect

最初に比較する四角形。

rect2
Rect

2 番目に比較する四角形。

戻り値

四角形が同じ Location 値と Size 値を持つ場合は true。それ以外の場合は false

次の例は、 メソッドを使用 Equals(Rect, Rect) して、1 つの四角形が別の四角形と等しいかどうかを判断する方法を示しています。

private bool rectEqualsExample2()
{
    // Create a rectangle.
    Rect myRectangle1 = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle1.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle1.Size = new Size(200, 50);

    // Create second rectangle to compare to the first.
    Rect myRectangle2 = new Rect();
    myRectangle2.Location = new Point(10, 5);
    myRectangle2.Size = new Size(200, 50);

    // Using the Equals method, see if the second rectangle is 
    // the same as the first rectangle. doesEqual is true because
    // both rectangles are exactly the same in that they both have the 
    // same location and size.
    bool doesEqual = Rect.Equals(myRectangle1, myRectangle2);

    return doesEqual;
}

注釈

この操作では、オブジェクトの等価性がテストされます。

この比較では、 の Double.NaN 2 つのインスタンスが等しいと見なされます。

注意

四角形の位置と寸法は、値によって Double 記述されます。 値を操作すると精度が失われる可能性があるため Double 、論理的に等しい 2 つの値の比較が失敗する可能性があります。

こちらもご覧ください

適用対象

Equals(Object)

指定したオブジェクトが現在の四角形と等しいかどうかを示します。

public:
 override bool Equals(System::Object ^ o);
public override bool Equals (object o);
override this.Equals : obj -> bool
Public Overrides Function Equals (o As Object) As Boolean

パラメーター

o
Object

現在の四角形と比較するオブジェクト。

戻り値

oRect で、現在の四角形と同じ Location および Size の値を持つ場合は true。それ以外の場合は false

次の例は、 メソッドを使用 Equals(Object) して、四角形が指定したオブジェクトと等しいかどうかを判断する方法を示しています。

private bool rectEqualsExample1()
{
    // Create a rectangle.
    Rect myRectangle1 = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle1.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle1.Size = new Size(200, 50);

    // Create second rectangle to compare to the first.
    Rect myRectangle2 = new Rect();
    myRectangle2.Location = new Point(10, 5);
    myRectangle2.Size = new Size(200, 50);

    // Using the Equals method, see if the second rectangle is the
    // same as the first rectangle. doesEqual is true because both
    // rectangles are exactly the same with respect to location and size. 
    bool doesEqual = myRectangle1.Equals(myRectangle2);

    return doesEqual;
}

注釈

この操作では、オブジェクトの等価性がテストされます。

この比較では、 の Double.NaN 2 つのインスタンスが等しいと見なされます。

注意

四角形の位置と寸法は、値によって Double 記述されます。 値を操作すると精度が失われる可能性があるため Double 、論理的に等しい 2 つの値の比較が失敗する可能性があります。

こちらもご覧ください

適用対象

Equals(Rect)

指定した四角形が現在の四角形と等しいかどうかを示します。

public:
 bool Equals(System::Windows::Rect value);
public bool Equals (System.Windows.Rect value);
override this.Equals : System.Windows.Rect -> bool
Public Function Equals (value As Rect) As Boolean

パラメーター

value
Rect

現在の四角形と比較する対象の四角形。

戻り値

指定した四角形が現在の四角形と同じ Location および Size の値を持つ場合は true。それ以外の場合は false

次の例は、 メソッドを Equals(Rect) 使用して、四角形が指定した四角形と等しいかどうかを判断する方法を示しています。

private bool rectEqualsExample1()
{
    // Create a rectangle.
    Rect myRectangle1 = new Rect();

    // The Location property specifies the coordinates of the upper left-hand 
    // corner of the rectangle. 
    myRectangle1.Location = new Point(10, 5);

    // Set the Size property of the rectangle with a width of 200
    // and a height of 50.
    myRectangle1.Size = new Size(200, 50);

    // Create second rectangle to compare to the first.
    Rect myRectangle2 = new Rect();
    myRectangle2.Location = new Point(10, 5);
    myRectangle2.Size = new Size(200, 50);

    // Using the Equals method, see if the second rectangle is the
    // same as the first rectangle. doesEqual is true because both
    // rectangles are exactly the same with respect to location and size. 
    bool doesEqual = myRectangle1.Equals(myRectangle2);

    return doesEqual;
}

注釈

この操作では、オブジェクトの等価性がテストされます。

この比較では、 の Double.NaN 2 つのインスタンスが等しいと見なされます。

注意

四角形の位置と寸法は、値によって Double 記述されます。 値を操作すると精度が失われる可能性があるため Double 、論理的に等しい 2 つの値の比較が失敗する可能性があります。

こちらもご覧ください

適用対象