Rect.Equals 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示两个矩形是否相等。
重载
Equals(Rect, Rect) |
指示指定的矩形是否相等。 |
Equals(Object) |
指示指定对象是否等于当前矩形。 |
Equals(Rect) |
指示指定矩形是否等于当前矩形。 |
Equals(Rect, Rect)
指示指定的矩形是否相等。
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
参数
- rect1
- Rect
要比较的第一个矩形。
- rect2
- Rect
要比较的第二个矩形。
返回
如果这些矩形具有相同的 Location 和 Size 值,则为 true
;否则为 false
。
示例
以下示例演示如何使用 Equals(Rect, Rect) 方法确定一个矩形是否等于另一个矩形。
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;
}
注解
此操作测试对象相等性。
在此比较中,的两个实例 Double.NaN 被视为相等。
另请参阅
适用于
Equals(Object)
指示指定对象是否等于当前矩形。
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
参数
- o
- Object
要与当前矩形进行比较的对象。
返回
如果 o
为 Rect,并且具有与当前矩形相同的 Location 和 Size 值,则为 true
;否则为 false
。
示例
以下示例演示如何使用 Equals(Object) 方法确定矩形是否等于指定的对象。
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;
}
注解
此操作测试对象相等性。
在此比较中,的两个实例 Double.NaN 被视为相等。
另请参阅
适用于
Equals(Rect)
指示指定矩形是否等于当前矩形。
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
参数
- value
- Rect
要与当前矩形进行比较的矩形。
返回
如果指定矩形具有与当前矩形相同的 Location 和 Size 值,则为 true
;否则为 false
。
示例
以下示例演示如何使用 Equals(Rect) 方法确定矩形是否等于指定的矩形。
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;
}
注解
此操作测试对象相等性。
在此比较中,的两个实例 Double.NaN 被视为相等。