英語で読む

次の方法で共有


Font.ToString メソッド

定義

この Fontの人間が判読できる文字列形式を返します。

C#
public override string ToString();

戻り値

この Fontを表す文字列。

次のコード例は Windows フォームで使用できるように設計されており、Paint イベント ハンドラーのパラメーターである PaintEventArgseが必要です。 このコードは、次のアクションを実行します。

  • Fontを作成します。

  • フォントを表す文字列を取得します。

  • メッセージ ボックスに文字列を表示します。

C#
public void ToString_Example(PaintEventArgs e)
{
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    // Get a string that represents myFont.
    string fontString = myFont.ToString();
             
    // Display a message box with fontString.
    MessageBox.Show(fontString);
}

注釈

返される文字列の形式は次のとおりです。

[フォント: Name=fontName, Size=size, Units=units, GDiCharSet=gdiCharSet, GdiVerticalFont=boolean]

適用対象

製品 バージョン
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.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 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10