Rect.Equality Operator (Rect, Rect)


Compares two rectangles for exact equality.

Namespace:   System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

Public Shared Operator = (
	rect1 As Rect,
	rect2 As Rect
) As Boolean


Type: System.Windows.Rect

The first rectangle to compare.

Type: System.Windows.Rect

The second rectangle to compare.

Return Value

Type: System.Boolean

true if the rectangles have the same Location and Size values; otherwise, false.

This operation tests for object equality.

In this comparison, two instances of Double.NaN are considered equal.


A rectangle's position and dimensions are described by Double values. Because Double values can lose precision when operated upon, a comparison between two values that are logically equal might fail.

The following example shows how to use the Equality operator to determine if two rectangles are exactly equal.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft