Partilhar via


Size3D.Equality(Size3D, Size3D) Operador

Definição

Compara a igualdade de duas estruturas Size3D. Duas estruturas Size3D são iguais se os valores de suas propriedades X, Y e Z são os mesmos.

public:
 static bool operator ==(System::Windows::Media::Media3D::Size3D size1, System::Windows::Media::Media3D::Size3D size2);
public static bool operator == (System.Windows.Media.Media3D.Size3D size1, System.Windows.Media.Media3D.Size3D size2);
static member ( = ) : System.Windows.Media.Media3D.Size3D * System.Windows.Media.Media3D.Size3D -> bool
Public Shared Operator == (size1 As Size3D, size2 As Size3D) As Boolean

Parâmetros

size1
Size3D

A primeira estrutura Size3D a ser comparada.

size2
Size3D

A segunda estrutura Size3D a ser comparada.

Retornos

true se os componentes X, Y e Z de size1 e size2 forem iguais; caso contrário, false.

Exemplos

O exemplo a seguir mostra como usar o operador de igualdade sobrecarregado para verificar se duas Size3D estruturas são iguais.

// Checks if two Size3D structures are equal using the overloaded == operator. 
// Returns a Boolean.

// Declaring Size3D structure without initializing x,y,z values
Size3D size1 = new Size3D();

// Declaring Size3D structure and initializing x,y,z values
Size3D size2 = new Size3D(5, 10, 15);
Boolean areEqual;

// Assigning values to size1
size1.X = 2;
size1.Y = 4;
size1.Z = 6;

// Checking for equality
areEqual = size1 == size2;

// areEqual is False

// Displaying Results
syntaxString = " areEqual = size1 == size2;";
resultType = "Boolean";
operationString = "Checking if two Size3D structures are equal";
ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
' Checks if two Size3D structures are equal using the overloaded == operator. 
' Returns a Boolean.

' Declaring Size3D structure without initializing x,y,z values
Dim size1 As New Size3D()

' Declaring Size3D structure and initializing x,y,z values
Dim size2 As New Size3D(5, 10, 15)
Dim areEqual As Boolean

' Assigning values to size1
size1.X = 2
size1.Y = 4
size1.Z = 6

' Checking for equality
areEqual = size1 = size2

' areEqual is False

' Displaying Results
syntaxString = " areEqual = size1 == size2"
resultType = "Boolean"
operationString = "Checking if two Size3D structures are equal"
ShowResults(areEqual.ToString(), syntaxString, resultType, operationString)

Comentários

Como Double os valores podem perder precisão quando operações aritméticas são executadas neles, uma comparação entre duas Size3D instâncias logicamente iguais pode falhar.

Aplica-se a

Confira também