Method ToString
ToString()
Returns a full-precision decimal form string representation of this value using the current culture.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
ToString(string?, IFormatProvider?)
Returns a string representation of this value.
Declaration
public string ToString(string? format, IFormatProvider? formatProvider = null)
Parameters
Type | Name | Description |
---|---|---|
string | format | The string format to use. The "G" format is used if none is provided. |
IFormatProvider | formatProvider | The format provider that will be used to obtain number format information. The current culture is used if none is provided. |
Returns
Type | Description |
---|---|
string |
Implements
Remarks
String format is composed of a format specifier followed by an optional precision specifier.
Format specifiers:
Specifier | Name | Description |
---|---|---|
"G" | General | Default format specifier if none is provided. Precision specifier determines the number of significant digits. If the precision specifier is omitted then the value is written out in full precision decimal form. If a precision specifier is provided then the more compact of either decimal form or scientific notation is used. |
"F" | Fixed-point | Precision specifier determines the number of decimal digits. Default value is NumberDecimalDigits. |
"N" | Number | Like fixed-point, but also outputs group separators. Precision specifier determines the number of decimal digits. Default value is NumberDecimalDigits. |
"E" | Exponential | Exponential (scientific) notation. Precision specifier determines the number of decimal digits. |
"C" | Currency | Precision specifier determines the number of decimal digits. Default value is CurrencyDecimalDigits. |
"P" | Percentage | Precision specifier determines the number of decimal digits. Default value is PercentDecimalDigits. |
"R" | Round-trip | Outputs the mantissa followed by E and then the exponent, always using the InvariantCulture. |