Single.ToString Method (String)
Converts the numeric value of this instance to its equivalent string representation, using the specified format.
Assembly: mscorlib (in mscorlib.dll)
The format parameter can be any valid standard numeric format specifier except for D and X, as well as any combination of custom numeric format specifiers. If format is null or an empty string, the return value is formatted with the general numeric format specifier ("G").
The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:
For more information about formatting, see Formatting Types.
Because the Single data type is not supported on the Macintosh OS X operating system, the string representation of a Single value may be different from those of the other .NET Framework numeric types that are supported by OS X.
The return value is formatted using the NumberFormatInfo object for the current culture. To apply the formatting conventions of a specified culture, call the Single.ToString(String, IFormatProvider) method.
By default, the return value only contains 7 digits of precision although a maximum of 9 digits is maintained internally. If the value of this instance has greater than 7 digits, returns PositiveInfinitySymbol or NegativeInfinitySymbol instead of the expected number. If you require more precision, specify format with the "G9" format specification, which always returns 9 digits of precision, or "R", which returns 7 digits if the number can be represented with that precision or 9 digits if the number can only be represented with maximum precision.
The following example displays several Single values using each of the supported standard numeric format specifiers together with two custom numeric format strings. One of those custom format strings illustrates how to pad a Single value with leading zeroes. In converting the numeric values to strings, the example uses the formatting conventions of the en-US culture.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.