Numeric Format Strings

Numeric format strings are used to control the formatting produced when a numeric data type is represented as a string. The overloads of ToString that exist in all numeric types, as described in the Formatting Overview, can be used with one of the numeric data types to control the precise behavior when converting a numeric type to a string. Additionally, numeric format strings can be used in conjunction with methods in several classes like Console and StreamWriter to format text. Numeric format strings fall into one of two categories: standard format strings and custom format strings.

Note that regardless of the format string, if a floating-point type (Single or Double) is positive or negative infinity, or NaN (Not a Number), the formatted string is the value of the respective PositiveInfinitySymbol, NegativeInfinitySymbol, or NaNSymbol specified by the currently applicable NumberFormatInfo object.

See Also

Formatting Types | Formatting Overview | Standard Numeric Format Strings | Custom Numeric Format Strings