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 Forms 使用,而且需要 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

適用於