Språk

Rect.Equals Metod

Definition

Anger om två rektanglar är lika med.

Överlagringar

Name Description
Equals(Rect, Rect)

Anger om de angivna rektanglarna är lika med.

Equals(Object)

Anger om det angivna objektet är lika med den aktuella rektangeln.

Equals(Rect)

Anger om den angivna rektangeln är lika med den aktuella rektangeln.

Equals(Rect, Rect)

Anger om de angivna rektanglarna är lika med.

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

Parametrar

rect1
Rect

Den första rektangel som ska jämföras.

rect2
Rect

Den andra rektangel som ska jämföras.

Returer

trueom rektanglarna har samma Location värden och Size annars . false

Exempel

I följande exempel visas hur du använder Equals(Rect, Rect) metoden för att avgöra om en rektangel är lika med en annan.

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

Kommentarer

Den här åtgärden testar objektjämlikhet.

I den här jämförelsen anses två instanser av Double.NaN vara lika.

Note

En rektangels position och dimensioner beskrivs med Double värden. Eftersom Double värden kan förlora precision när de används kan en jämförelse mellan två värden som är logiskt lika med misslyckas.

Se även

Gäller för

Equals(Object)

Anger om det angivna objektet är lika med den aktuella rektangeln.

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

Parametrar

o
Object

Objektet som ska jämföras med den aktuella rektangeln.

Returer

true om o är en Rect och har samma Location värden och Size värden som den aktuella rektangeln, falseannars .

Exempel

I följande exempel visas hur du använder Equals(Object) metoden för att avgöra om en rektangel är lika med ett angivet objekt.

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

Kommentarer

Den här åtgärden testar objektjämlikhet.

I den här jämförelsen anses två instanser av Double.NaN vara lika.

Note

En rektangels position och dimensioner beskrivs med Double värden. Eftersom Double värden kan förlora precision när de används kan en jämförelse mellan två värden som är logiskt lika med misslyckas.

Se även

Gäller för

Equals(Rect)

Anger om den angivna rektangeln är lika med den aktuella rektangeln.

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

Parametrar

value
Rect

Den rektangel som ska jämföras med den aktuella rektangeln.

Returer

true om den angivna rektangeln har samma Location värden och Size värden som den aktuella rektangeln, falseannars .

Exempel

I följande exempel visas hur du använder Equals(Rect) metoden för att avgöra om en rektangel är lika med en angiven rektangel.

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

Kommentarer

Den här åtgärden testar objektjämlikhet.

I den här jämförelsen anses två instanser av Double.NaN vara lika.

Note

En rektangels position och dimensioner beskrivs med Double värden. Eftersom Double värden kan förlora precision när de används kan en jämförelse mellan två värden som är logiskt lika med misslyckas.

Se även

Gäller för