To C#-1 Notes

Tables of Format Strings

 

Standard Numeric Format Strings

Format Character Meaning
C or c Currency
E or e Scientific Format
F or f Fixed-point Format
G or g General Format1
N or n Numeric Format
X or x Hexadecimal Format

1 Either scientific or fixed-point, depending on the value.

 

Picture Numeric Format Strings

Format Character Meaning
0 Display digit even if nonsignificant zero.
# Only display digit if significant.
. Decimal point
, Group separator
% Literal percent character
\ Escape character (\n, \t, etc.)
"" Literal string
; Alternative formatting for positive, negative, or zero.

 

Date Format Strings

Format Character Description Specification
d Short date MM/dd/yyyy
D Long date dddd, MMMM dd/yyyy
f Long date followed by short time MM/dd/yyyy HH:mm
F Long date followed by long time MM/dd/yyyy HH:mm:ss
g Short date followed by short time MM/dd/yyyy HH:mm
G Short date followed by long time MM/dd/yyyy HH:mm:ss
m or M Month/day MMMM dd
r or R IETF RFC 1123 specification ddd,dd,MMM,yyyy HH:mm:ssGMT
s Sortable date/time yyy-MM-dd HH:mm:ss
t Short time HH:mm
T Long time HH:mm:ss
u Universal date/time dddd,MMMM dd,yyyy HH:mm:ss
y Year month MMMM, yyyy