Font.Equals(Object) メソッド

定義

指定したオブジェクトが Font であり、この FontFamily と同じ GdiVerticalFontGdiCharSetStyleSizeUnit、および Font の各プロパティ値を保有しているかどうかを示します。

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 と同じ FontFamilyGdiVerticalFontGdiCharSetStyleSize、および Unit の各プロパティ値を保有している場合は true。それ以外の場合は false

次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 このコードでは、2 つの 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

適用対象