Font.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳一個人類可讀的字串表示。Font
public:
override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
傳回
一串代表此 Font的字串。
範例
以下程式碼範例是為 Windows Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:
建立 Font。
會得到一個字串代表字體。
在訊息框中顯示字串。
public:
void ToString_Example( PaintEventArgs^ /*e*/ )
{
// Create a Font object.
System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );
// Get a string that represents myFont.
String^ fontString = myFont->ToString();
// Display a message box with fontString.
MessageBox::Show( fontString );
}
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);
}
Public Sub ToString_Example(ByVal e As PaintEventArgs)
' Create a Font object.
Dim myFont As New Font("Arial", 16)
' Get a string that represents myFont.
Dim fontString As String = myFont.ToString()
' Display a message box with fontString.
MessageBox.Show(fontString)
End Sub
備註
回傳的字串格式如下:
[字型:name=fontName, Size=size, Units=units, GDiCharSet=gdiCharSet, GdiVerticalFont=boolean]