Font.Equals(Object) Font.Equals(Object) Font.Equals(Object) Font.Equals(Object) Method

定義

表示指定的物件是否為 Font,而且是否具有與這個 Font 相同的 FontFamilyGdiVerticalFontGdiCharSetStyleSizeUnit 屬性值。Indicates whether the specified object is a Font and has the same FontFamily, GdiVerticalFont, GdiCharSet, Style, Size, and Unit property values as this Font.

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

參數

obj
Object Object Object Object

要測試的物件。The object to test.

傳回

如果 obj 參數為 Font 而且具有與這個 Font 相同的 FontFamilyGdiVerticalFontGdiCharSetStyleSizeUnit 屬性值,則為 true;否則為 falsetrue if the obj parameter is a Font and has the same FontFamily, GdiVerticalFont, GdiCharSet, Style, Size, and Unit property values as this Font; otherwise, false.

範例

下列程式碼範例是針對與 Windows Forms 搭配使用所設計, 而且PaintEventArgs它需要e, 這Paint是事件處理常式的參數。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 程式碼會建立Font兩個物件, 然後測試它們是否相等。The code creates two Font objects and then tests whether they are equivalent.

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

適用於