.NET: String Format Characters

C or c: currency based on local cultural symbol, $1234.56
D or d: decimal, optional number (i.e. {0:D8}) used to pad value, 012345678
E or e: exponential notation, 1.234E+05
F or f: fixed point, 0:F3 1234.567
G or g: general, used to format to fixed or exponential
N or n: numerical format (with commas), 1,234.00
X or x: hexadecimal, 0:X 123F, 0:x 123f

You can use this with string.Format, like below:

Leave a Reply

Your email address will not be published. Required fields are marked *