Rect.Equals Methode

Definition

Gibt an, ob zwei Rechtecke gleich sind.

Überlädt

Name Beschreibung
Equals(Rect, Rect)

Gibt an, ob die angegebenen Rechtecke gleich sind.

Equals(Object)

Gibt an, ob das angegebene Objekt dem aktuellen Rechteck entspricht.

Equals(Rect)

Gibt an, ob das angegebene Rechteck dem aktuellen Rechteck entspricht.

Equals(Rect, Rect)

Gibt an, ob die angegebenen Rechtecke gleich sind.

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

Parameter

rect1
Rect

Das erste zu vergleichende Rechteck.

rect2
Rect

Das zweite zu vergleichende Rechteck.

Gibt zurück

true wenn die Rechtecke dieselben Location Werte haben, Size andernfalls false.

Beispiele

Im folgenden Beispiel wird gezeigt, wie Sie mithilfe der Equals(Rect, Rect) Methode ermitteln, ob ein Rechteck mit einem anderen identisch ist.

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;
}

Hinweise

Dieser Vorgang testet auf die Objektgleichheit.

In diesem Vergleich werden zwei Instanzen Double.NaN gleich angesehen.

Note

Die Position und Abmessungen eines Rechtecks werden durch Double Werte beschrieben. Da Double Werte bei der Arbeit an Genauigkeit verlieren können, kann ein Vergleich zwischen zwei Werten, die logisch gleich sind, fehlschlagen.

Weitere Informationen

Gilt für:

Equals(Object)

Gibt an, ob das angegebene Objekt dem aktuellen Rechteck entspricht.

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

Parameter

o
Object

Das Objekt, das mit dem aktuellen Rechteck verglichen werden soll.

Gibt zurück

true if o is a Rect and has the same Location and Size values as the current rectangle; otherwise, false.

Beispiele

Das folgende Beispiel zeigt, wie Sie mithilfe der Equals(Object) Methode ermitteln, ob ein Rechteck mit einem angegebenen Objekt identisch ist.

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;
}

Hinweise

Dieser Vorgang testet auf die Objektgleichheit.

In diesem Vergleich werden zwei Instanzen Double.NaN gleich angesehen.

Note

Die Position und Abmessungen eines Rechtecks werden durch Double Werte beschrieben. Da Double Werte bei der Arbeit an Genauigkeit verlieren können, kann ein Vergleich zwischen zwei Werten, die logisch gleich sind, fehlschlagen.

Weitere Informationen

Gilt für:

Equals(Rect)

Gibt an, ob das angegebene Rechteck dem aktuellen Rechteck entspricht.

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

Parameter

value
Rect

Das Rechteck, das mit dem aktuellen Rechteck verglichen werden soll.

Gibt zurück

true wenn das angegebene Rechteck die gleichen Location Werte wie Size das aktuelle Rechteck aufweist; andernfalls false.

Beispiele

Das folgende Beispiel zeigt, wie Sie mithilfe der Equals(Rect) Methode ermitteln können, ob ein Rechteck mit einem angegebenen Rechteck identisch ist.

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;
}

Hinweise

Dieser Vorgang testet auf die Objektgleichheit.

In diesem Vergleich werden zwei Instanzen Double.NaN gleich angesehen.

Note

Die Position und Abmessungen eines Rechtecks werden durch Double Werte beschrieben. Da Double Werte bei der Arbeit an Genauigkeit verlieren können, kann ein Vergleich zwischen zwei Werten, die logisch gleich sind, fehlschlagen.

Weitere Informationen

Gilt für: