英語で読む

次の方法で共有


Font.Equals(Object) メソッド

定義

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

C#
public override bool Equals (object? obj);
C#
public override bool Equals (object obj);

パラメーター

obj
Object

テストするオブジェクト。

戻り値

obj パラメーターが Font で、この Fontと同じ FontFamilyGdiVerticalFontGdiCharSetStyleSize、および Unit プロパティ値を持っている場合に true します。それ以外の場合は、false

次のコード例は Windows フォームで使用できるように設計されており、Paint イベント ハンドラーのパラメーターである PaintEventArgseが必要です。 このコードでは、2 つの Font オブジェクトを作成し、それらが同等であるかどうかをテストします。

C#
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());
}

適用対象

製品 バージョン
.NET 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9