A program uses format specifiers to determine how objects are represented as strings. C# provides two kinds of specifiers: standard format specifiers and custom format specifiers. Standard format specifiers are locale-aware, so the result depends on the computer’s regional settings. If a program uses standard format specifiers and you run the program in a new locale, it automatically produces the formats appropriate for that locale. For that reason, you should always use the standard specifiers whenever possible.
The following sections describe the standard and custom format specifiers.
Standard numeric format specifiers enable you to easily display commonly used numeric formats. The following table lists the standard numeric specifiers.
|Currency. If a precision specifier follows the |
|Decimal. This specifier works only with integer types. It simply displays the number’s digits. If a precision specifier follows the |
|Scientific notation. The result always has exactly ...|