Partager via


Double.ToString Method (String)

Converts the value of the current Double object to its equivalent string representation, using a specified format.

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

Syntax

public string ToString (
         string format
)

Parameters

  • format
    A string that takes the form Axx, where A is an alphabetic character called the format specifier, and xx is an optional integer called the precision specifier. The precision specifier ranges from 0 to 99 and affects the number of digits in the result.

    If format is a null reference or an empty string, the general format specifier, 'G', is used.

    The following table describes the standard Double format specifiers.

    Format specifier Name Description
    F or f Fixed Point

    The number is converted to a string of the form "ddd.ddd…" where each 'd' indicates a digit (0-9), prefixed by a minus sign if the number is negative.

    The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision is 2.

    G or g General

    The number is converted to a string of decimal digits (0-9), prefixed by a minus sign if the number is negative. The precision specifier is ignored.

    N or n Number The number is converted to a string of the form "-d,ddd,ddd.ddd…", where '-' indicates a negative symbol if required, 'd' indicates a digit (0-9), ',' indicates a thousand separator between number groups, and '.' indicates a decimal point symbol. The actual number group size and thousand separator are specified by the current NumberFormatInfo object. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision is 2.

Return Value

A string representation of the value of the current Double object, in the specified format.

Version Information

Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, 4.1, and 4.2.

See Also

Reference

Double Structure
Double Members
System Namespace