Information Technology Reference
In-Depth Information
Table 23-2.
Continued
Name and Characters
Meaning
Percent
P
,
p
A string that represents percent. The number is multiplied by 100.
Precision specifier: The number of decimal places.
Sample:
Console.WriteLine("{0 :P2}", 0.1221897);
Output:
12.22 %
Round-trip
R
,
r
The output string is chosen so that if the string is converted back to a
numeric value using a
Parse
method, the result will be the original
value.
Precision specifier: Ignored.
Sample:
Console.WriteLine("{0 :R}", 1234.21897);
Output:
1234.21897
Hexadecimal
X
,
x
Case sensitive
A string of hexadecimal digits. The hex digits A-F will match the case of
the specifier.
Precision specifier: The minimum number of digits to use in the output
string. If the number has fewer digits, it will be padded with 0s on the left.
Sample:
Console.WriteLine("{0 :x}", 180026);
Output:
2bf3a