Rect.Equals Método

Definição

Indica se os dois retângulos são iguais.

Sobrecargas

Equals(Rect, Rect)

Indica se os retângulos especificados são iguais.

Equals(Object)

indica se o objeto especificado é igual ao retângulo atual.

Equals(Rect)

indica se o retângulo especificado é igual ao retângulo atual.

Equals(Rect, Rect)

Indica se os retângulos especificados são iguais.

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

Parâmetros

rect1
Rect

O primeiro retângulo para comparar.

rect2
Rect

O segundo retângulo a ser comparado.

Retornos

true se os retângulos tiverem os mesmos valores Location e Size; caso contrário, false.

Exemplos

O exemplo a seguir mostra como usar o Equals(Rect, Rect) método para determinar se um retângulo é igual a outro.

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

Comentários

Esta operação testa a igualdade de objetos.

Nessa comparação, duas instâncias de Double.NaN são consideradas iguais.

Observação

A posição e as dimensões de um retângulo são descritas por Double valores. Como Double os valores podem perder precisão quando operados, uma comparação entre dois valores logicamente iguais pode falhar.

Confira também

Aplica-se a

Equals(Object)

indica se o objeto especificado é igual ao retângulo atual.

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

Parâmetros

o
Object

O objeto a comparar ao retângulo atual.

Retornos

true se o for um Rect e tiver os mesmos valores Location e Size que o retângulo atual; caso contrário, false.

Exemplos

O exemplo a seguir mostra como usar o Equals(Object) método para determinar se um retângulo é igual a um objeto especificado.

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

Comentários

Esta operação testa a igualdade de objetos.

Nessa comparação, duas instâncias de Double.NaN são consideradas iguais.

Observação

A posição e as dimensões de um retângulo são descritas por Double valores. Como Double os valores podem perder precisão quando operados, uma comparação entre dois valores logicamente iguais pode falhar.

Confira também

Aplica-se a

Equals(Rect)

indica se o retângulo especificado é igual ao retângulo atual.

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

Parâmetros

value
Rect

O retângulo a ser comparado ao retângulo atual.

Retornos

true se o retângulo especificado tiver os mesmos valores Location e Size que o retângulo atual; caso contrário, false.

Exemplos

O exemplo a seguir mostra como usar o Equals(Rect) método para determinar se um retângulo é igual a um retângulo especificado.

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

Comentários

Esta operação testa a igualdade de objetos.

Nessa comparação, duas instâncias de Double.NaN são consideradas iguais.

Observação

A posição e as dimensões de um retângulo são descritas por Double valores. Como Double os valores podem perder precisão quando operados, uma comparação entre dois valores logicamente iguais pode falhar.

Confira também

Aplica-se a