2009年1月29日 星期四

C# string.Format

C# string.Format, reference from zbwmx的專欄

Symbol

example

output

C string.Format("{0:C3}", 2) $2.000
D string.Format("{0:D3}", 2) 002
E 1.20E+001 1.20E+001
G string.Format("{0:G}", 2) 2
N string.Format("{0:N}", 250000) 250,000.00
X string.Format("{0:X000}", 12) C

string.Format("{0:000.000}", 12.2) 012.200


DateTime.ToString() Patterns
MM/dd/yyyy 08/22/2006
dddd, dd MMMM yyyy Tuesday, 22 August 2006
dddd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
dddd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
dddd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
dddd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
MM/dd/yyyy HH:mm 08/22/2006 06:30
MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
MM/dd/yyyy H:mm 08/22/2006 6:30
MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
MMMM dd August 22
MMMM dd August 22
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07
HH:mm 06:30
hh:mm tt 06:30 AM
H:mm 6:30
h:mm tt 6:30 AM
HH:mm:ss 06:30:07
yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z
dddd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
yyyy MMMM 2006 August
yyyy MMMM 2006 August


沒有留言:

Powered By Blogger