NET String Formatting Flags

If you require more elaborate formatting, each placeholder can optionally contain various format characters. Each format character can be typed in either uppercase or lowercase with little or no consequence. Table 3-3 shows your core formatting options.

Table 3-3. .NET String Format Characters String Format Character Meaning in Life

C or c Used to format currency. By default, the flag will prefix the local cultural symbol (a dollar sign [$] for U.S. English).

D or d Used to format decimal numbers. This flag may also specify the minimum number of digits used to pad the value.

E or e Used for exponential notation.

F or f Used for fixed-point formatting.

G or g Stands for general. This character can be used to format a number to fixed or exponential format.

Continued

Table 3-3. Continued

String Format Character

Meaning in Life

N or n

Used for basic numerical formatting (with commas).

X or x

Used for hexadecimal formatting. If you use an uppercase "X", your hex

Was this article helpful?

0 0

Post a comment