This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Formatting String

Hướng dẫn sử dụng String.Format

Video hướng dẫn sử dụng string.Format: Click here

Formatting String
example
output
String.Format(“–{0,10}–”, “test”);–      test–
String.Format(“–{0,-10}–”, “test”);–test      –

Formatting number

specifier
type
format
output
(double 1.2345)
output
(int -12345)
ccurrency{0:c}£1.23-£12,345.00
ddecimal
(whole number)
{0:d}System.FormatException-12345
eexponent / scientific{0:e}1.234500e+000-1.234500e+004
ffixed point{0:f}1.23-12345.00
ggeneral{0:g}1.2345-12345
nnumber{0:n}1.23-12,345.00
rround trippable{0:r}1.23System.FormatException
xhexadecimal{0:x4}System.FormatExceptionffffcfc7

 Custom number formatting

specifier
type
format
output
(double 1234.56)
0zero placeholder{0:00.000}1234.560
#digit placeholder{0:#.##}1234.56
.decimal point placeholder{0:0.0}1234.6
,thousand separator{0:0,0}1,235
%percentage{0:0%}123456%
Date formatting
specifier
type
output
(June 8, 1970 12:30:59)
dShort Date08/06/1970
DLong Date08 June 1970
tShort Time12:30
TLong Time12:30:59
fFull date and time08 June 1970 12:30
FFull date and time (long)08 June 1970 12:30:59
gDefault date and time08/06/1970 12:30
GDefault date and time (long)08/06/1970 12:30:59
MDay / Month8 June
rRFC1123 date stringMon, 08 Jun 1970 12:30:59 GMT
sSortable date/time1970-06-08T12:30:59
uUniversal time, local timezone1970-06-08 12:30:59Z
YMonth / YearJune 1970

 Custom date formatting

specifier
type
output
(June 8, 1970 12:30:59)
ddDay08
dddShort Day NameMon
ddddFull Day NameMonday
hh2 digit hour12
HH2 digit hour (24 hour)12
mm2 digit minute30
MMMonth06
MMMShort Month nameJun
MMMMMonth nameJune
ssseconds59
ttAM/PMPM
yy2 digit year70
yyyy4 digit year1970
:seperator, e.g. {0:hh:mm:ss}12:30:59
/seperator, e.g. {0:dd/MM/yyyy}08/06/1970
Culture information
String.Format() cho phép overload chấp nhận tham số CultureInfo. Từ đó, giúp cho các lập trình viên có thể viết được các chương trình phù hợp với những vùng văn hóa khác nhau. Ví dụ, các tên tháng sẽ thay đổi theo thiết lập cục bộ trong máy của bạn. Thay vì gọi đơn giản gọi phương thức String.Format(), bạn nên chú ý đến việc dùng overload này. Nếu bạn không muốn xác định culture, bạn có thể dùng System.Globalization.CultureInfo.InvariantCulture. Điều này sẽ đặt thiết lập định dạng mặc định là English, và sẽ thay thế cho culture trong thread hiện tại.