FontFamily.Equals(Object) 方法

定义

指示指定的对象是否为 FontFamily 以及是否与此 FontFamily 相等。

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

要测试的对象。

返回

如果 objFontFamily 且与此 FontFamily 相等,则为 true;否则为 false

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建两个 Font 对象。

  • 测试它们是否等效。

  • 在消息框中显示测试结果。

public:
   void Equals_Example( PaintEventArgs^ /*e*/ )
   {
      // Create two FontFamily objects.
      FontFamily^ firstFontFamily = gcnew FontFamily( "Arial" );
      FontFamily^ secondFontFamily = gcnew FontFamily( "Times New Roman" );

      // Check to see if the two font families are equivalent.
      bool equalFonts = firstFontFamily->Equals( secondFontFamily );

      // Display the result of the test in a message box.
      MessageBox::Show( equalFonts.ToString() );
   }
public void Equals_Example(PaintEventArgs e)
{
    // Create two FontFamily objects.
    FontFamily firstFontFamily = new FontFamily("Arial");
    FontFamily secondFontFamily = new FontFamily("Times New Roman");
             
    // Check to see if the two font families are equivalent.
    bool equalFonts = firstFontFamily.Equals(secondFontFamily);
             
    // Display the result of the test in a message box.
    MessageBox.Show(equalFonts.ToString());
}
Public Sub Equals_Example(ByVal e As PaintEventArgs)

    ' Create two FontFamily objects.
    Dim firstFontFamily As New FontFamily("Arial")
    Dim secondFontFamily As New FontFamily("Times New Roman")

    ' Check to see if the two font families are equivalent.
    Dim equalFonts As Boolean = _
    firstFontFamily.Equals(secondFontFamily)

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

适用于