Share via


Font.Equals(Object) Metode

Definisi

Menunjukkan apakah objek yang ditentukan adalah Font dan memiliki nilai properti , , GdiCharSetGdiVerticalFont, Style, Size, dan Unit yang sama FontFamilydengan iniFont.

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

Parameter

obj
Object

Objek yang akan diuji.

Mengembalikan

trueobj jika parameter adalah Font dan memiliki nilai properti , , GdiCharSetGdiVerticalFont, Style, Size, dan Unit yang sama FontFamilyseperti ini Font; jika tidak, false.

Contoh

Contoh kode berikut dirancang untuk digunakan dengan Formulir Windows, dan memerlukan PaintEventArgse, yang merupakan parameter penanganan Paint aktivitas. Kode ini membuat dua Font objek lalu menguji apakah objek tersebut setara.

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

Berlaku untuk