Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Single.ToString Method

Updated: October 2008

Converts the numeric value of this instance to its equivalent string representation.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public override string ToString()

Return Value

Type: System.String
The string representation of the value of this instance.

The return value can be PositiveInfinitySymbol, NegativeInfinitySymbol, NaNSymbol, or a string of the form:


Optional elements are framed in square brackets ([ and ]). Elements that contain the term "digits" consist of a series of numeric characters ranging from 0 to 9. The following table lists each element:




A negative sign or positive sign symbol.


A series of digits specifying the integral part of the number. Integral-digits can be absent if there are fractional-digits.


A culture-specific decimal point symbol.


A series of digits specifying the fractional part of the number.


A lowercase character 'e', indicating exponential (scientific) notation.


A series of digits specifying an exponent.

Some examples of the return value are "100", "-123,456,789", "123.45e+6", "500", "3.1416", "600", "-0.123", and "-Infinity".

This overload of the ToString method implicitly uses the general numeric format specifier ("G") and the NumberFormatInfo object for the current culture.

The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

The following example uses the default Single.ToString method to display the string representations of a number of Single values.

float number;

number = 1.6E20F;
// Displays 1.6E+20.

number = 1.6E2F;
// Displays 160.

number = -3.541F;
// Displays -3.541.

number = -1502345222199E-07F;
// Displays -150234.5222199.

number = -15023452221990199574E-09F;
// Displays -15023452221.9902.

number = .60344F;
// Displays 0.60344.

number = .000000001F;
// Displays 1E-09.

The following code example illustrates the use of the Parse(String) method along with the ToString() method.

bool done = false;
string inp;
    Console.Write("Enter a real number: ");
    inp = Console.ReadLine();
        s = Single.Parse(inp);
        Console.WriteLine("You entered {0}.", s.ToString());
        done = true;
    catch (FormatException)
        Console.WriteLine("You did not enter a number.");
    catch (Exception e)
        Console.WriteLine("An exception occurred while parsing your response: {0}", e.ToString());
} while (!done);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0




October 2008

Extensively revised the documentation for this overload.

Information enhancement.

Community Additions

© 2018 Microsoft