Export (0) Print
Expand All

Double.ToString Method (String)

.NET Framework 1.1

Converts the numeric value of this instance to its equivalent string representation, using the specified format.

[Visual Basic]
Overloads Public Function ToString( _
   ByVal format As String _
) As String
[C#]
public string ToString(
 string format
);
[C++]
public: String* ToString(
 String* format
);
[JScript]
public function ToString(
   format : String
) : String;

Parameters

format
A format string.

Return Value

The string representation of the value of this instance as specified by format.

Exceptions

Exception Type Condition
FormatException format is invalid.

Remarks

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

[sign]integral-digits[.[fractional-digits]][e[sign]exponential-digits]

Optional items are framed in square brackets ([ and ]). Items containing the term "digits" consist of a series of numeric characters ranging from 0 to 9.

sign
A negative sign or positive sign symbol.
integral-digits
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.
fractional-digits
A series of digits specifying the fractional part of the number.
'e'
A lowercase character 'e', indicating exponential (scientific) notation.
exponential-digits
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".

If format is a null reference (Nothing in Visual Basic) or an empty string, the return value is formatted with the general format specifier ("G").

By default, the return value only contains 15 digits of precision although a maximum of 17 digits is maintained internally. If the value of this instance has greater than 15 digits, ToString returns PositiveInfinitySymbol or NegativeInfinitySymbol instead of the expected number. If you require more precision, specify format with the "G17" format specification, which always returns 17 digits of precision, or "R", which returns 15 digits if the number can be represented with that precision or 17 digits if the number can only be represented with maximum precision.

The return value is formatted with NumberFormatInfo data for the current culture.

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, Common Language Infrastructure (CLI) Standard

See Also

Double Structure | Double Members | System Namespace | Double.ToString Overload List | Formatting Overview | Numeric Format Strings | Parse | String

Show:
© 2014 Microsoft