Export (0) Print
Expand All

Font.ToString Method

Returns a human-readable string representation of this Font object.

[Visual Basic]
Overrides Public Function ToString() As String
[C#]
public override string ToString();
[C++]
public: String* ToString();
[JScript]
public override function ToString() : String;

Return Value

A string that represents this Font object.

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates a Font object.
  • Gets a string represents the font.
  • Displays the string in a message box.
[Visual Basic] 
Public Sub ToString_Example(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
        
[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);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Font Class | Font Members | System.Drawing Namespace

Show:
© 2014 Microsoft