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 物件的相等性。 由於 ColorStylusTip 上的 HeightWidthattributes1attributes2 屬性都設定為相同的值,因此會出現「The DrawingAttributes are iqual」的訊息。

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若以下性質相等,則兩個物體相等:

Note

Equals 方法不會檢查自訂屬性的相等性。

適用於

另請參閱