Font.Equals(Object) 方法

定义

指示指定对象是否为 Font,以及是否具有与此 FontFamily 相同的 GdiVerticalFontGdiCharSetStyleSizeUnitFont 属性值。

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
public override bool Equals (object? obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

参数

obj
Object

要测试的对象。

返回

如果 obj 参数为 Font 并且具有与此 Font 相同的 FontFamilyGdiVerticalFontGdiCharSetStyleSizeUnit 属性值,则为 true;否则为 false

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 该代码创建两个 Font 对象,然后测试它们是否等效。

public:
   void Equals_Example( PaintEventArgs^ /*e*/ )
   {
      // Create a Font object.
      System::Drawing::Font^ firstFont = gcnew System::Drawing::Font( "Arial",16 );

      // Create a second Font object.
      System::Drawing::Font^ secondFont = gcnew System::Drawing::Font( gcnew FontFamily( "Arial" ),16 );

      // Test to see if firstFont is identical to secondFont.
      bool fontTest = firstFont->Equals( secondFont );

      // Display a message box with the result of the test.
      MessageBox::Show( fontTest.ToString() );
   }
public void Equals_Example(PaintEventArgs e)
{
    // Create a Font object.
    Font firstFont = new Font("Arial", 16);
             
    // Create a second Font object.
    Font secondFont = new Font(new FontFamily("Arial"), 16);
             
    // Test to see if firstFont is identical to secondFont.
    bool fontTest = firstFont.Equals(secondFont);
             
    // Display a message box with the result of the test.
    MessageBox.Show(fontTest.ToString());
}
Public Sub Equals_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim firstFont As New Font("Arial", 16)

    ' Create a second Font object.
    Dim secondFont As New Font(New FontFamily("Arial"), 16)

    ' Test to see if firstFont is identical to secondFont.
    Dim fontTest As Boolean = firstFont.Equals(secondFont)

    ' Display a message box with the result of the test.
    MessageBox.Show(fontTest.ToString())
End Sub

适用于