Size3D.Equals Method (Size3D, Size3D)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Compares two Size3D structures for equality. Two Size3D structures are equal if the values of their X, Y, and Z properties are the same.

Namespace:   System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)

public static bool Equals(
	Size3D size1,
	Size3D size2
)

Parameters

size1
Type: System.Windows.Media.Media3D.Size3D

The first Size3D structure to compare.

size2
Type: System.Windows.Media.Media3D.Size3D

The second Size3D structure to compare.

Return Value

Type: System.Boolean

true if instances are equal; otherwise, false.

true if the X, Y, and Z components of size1 and size2 are equal; otherwise, false.

Because Double values can lose precision when arithmetic operations are performed on them, a comparison between two Size3D instances that are logically equal might fail.

The following example shows how to check if two Size3D structures are equal.

private bool size3DEqualityExample()
{

    // Checks if two Size3D structures are equal using the static Equals method. 
    // Returns a Boolean.

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

    // Delcaring 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 = Size3D.Equals(size1, size2);

    // areEqual is False
    return areEqual;

}

.NET Framework
Available since 3.0
Return to top
Show: