Specifier | Description | Effect of Precision Specifier |
C or c | Formats the number as a monetary value including the correct number of decimal places and the appropriate currency symbol for the user's local setting | Specifies a fixed number of decimal places. |
D or d | Formats integers only as simple whole numbers. | Specifies the minimum number of digits. Leading zeroes are added if required. |
E | Formats numbers using exponential notation <https://en.wikipedia.org/wiki/Exponential_notation>. The resultant string includes an upper case letter 'E'.Specifies a fixed number of decimal places for the mantissa. If omitted, six decimal places are used. | |
e | Formats numbers using exponential notation. The resultant string includes an lower case letter 'e'. | Specifies a fixed number of decimal places for the mantissa. If omitted, six decimal places are used. |
F or f | Formats numbers using fixed point notation. | Specifies a fixed number of decimal places. |
G or g | Formats numbers using either exponential or fixed point notation, whichever produces the shortest string. The actual results vary according to the data type being converted and whether a precision specifier is used. | See 'e', 'E' and 'F or f'. |
N or n | Formats numbers using fixed point notation with thousands separators. | Specifies a fixed number of decimal places. |
P or p | Formats numbers using percentage notation. For example, 0.25 is formatted as 25%. | Specifies a fixed number of decimal places. |
R or r | Formats numbers using Round-Trip Format. This is a special format that ensures that the string generated can be converted back to the original number using Parse methods. | Unused. |
X | Converts numbers into a string representation of their hexadecimal value. The digits 0 to 9 and A to F are used. | Specifies the minimum number of digits. Leading zeroes are added if required. |
x | Converts numbers into a string representation of their hexadecimal value. The digits 0 to 9 and a to f are used. | Specifies the minimum number of digits. Leading zeroes are added if required |