DrawingAttributes.Equals(Object) 方法

定义

确定指定的 DrawingAttributes 对象是否等同于当前的 DrawingAttributes

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

要与当前 DrawingAttributes 对象进行比较的 DrawingAttributes 对象。

返回

如果对象相同,则为 true;否则为 false

示例

以下示例比较两 DrawingAttributes 个 对象的相等性。 Color由于 和 attributes2 上的 attributes1StylusTipHeightWidth 属性设置为相同的值,因此将显示“DrawingAttributes 相等”消息。

DrawingAttributes attributes1 = new DrawingAttributes();
attributes1.Color = Colors.Blue;
attributes1.StylusTip = StylusTip.Rectangle;
attributes1.Height = 5;
attributes1.Width = 5;

DrawingAttributes attributes2 = new DrawingAttributes();
attributes2.Color = Colors.Blue;
attributes2.StylusTip = StylusTip.Rectangle;
attributes2.Height = 5;
attributes2.Width = 5;
Dim attributes1 As New DrawingAttributes()
attributes1.Color = Colors.Blue
attributes1.StylusTip = StylusTip.Rectangle
attributes1.Height = 5
attributes1.Width = 5

Dim attributes2 As New DrawingAttributes()
attributes2.Color = Colors.Blue
attributes2.StylusTip = StylusTip.Rectangle
attributes2.Height = 5
attributes2.Width = 5
if (attributes1.Equals(attributes2))
{
    MessageBox.Show("The DrawingAttributes are equal");
}
else
{
    MessageBox.Show("The DrawingAttributes are not equal");
}
If attributes1.Equals(attributes2) Then
    MessageBox.Show("The DrawingAttributes are equal")
Else
    MessageBox.Show("The DrawingAttributes are not equal")
End If

注解

如果以下属性相等,则两 DrawingAttributes 个 对象相等:

注意

方法 Equals 不检查自定义属性是否相等。

适用于

另请参阅