Rect.Inequality(Rect, Rect) Operador

Definição

Compara dois retângulos quanto à desigualdade.

public static bool operator != (System.Windows.Rect rect1, System.Windows.Rect rect2);

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 não tiverem os mesmos valores Location e Size; caso contrário, false.

Exemplos

O exemplo a seguir mostra como usar o Inequality operador para determinar se dois retângulos não são exatamente iguais.

private Boolean overloadedInequalityOperatorExample()
{
    // Initialize new rectangle.
    Rect myRectangle = new Rect();

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

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

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

    // Check if the two Rects are not equal using the overloaded inequality operator.
    // notEqual is true because although the size of each rectangle is the same,
    // the locations are different.
    bool notEqual = (myRectangle != myRectangle2);

    // Returns true.
    return notEqual;
}

Comentários

Esta operação testa a desigualdade de objeto.

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.

O método equivalente para esse operador é Rect.Equals(Rect, Rect)

Aplica-se a

Produto Versões
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9