반응형

1. 소숫자리수 표현

 string.Format("{0:f2}%",23.44555);

결과 => 23.44%

 

string.Format("{0:00}%",23.44555);

결과 => 23%

 

2.숫자 1000 단위 마다 콤마(,) 추가하기

int cnt = 45646

string str string.Format("{0:#,###}", cnt));

 

 결과 => 45,646

 

 

3. 0000 채워 넣기

string str = string.Format("{0:D4}", 22);

결과 => 0022

 

 


4. 백분율로 나타내기

string.Format("{0:P}", 0.2189);

결과 => 21.89%

string.Format("{0:P1}", 0.2189);

결과 => 21.8%

반응형

+ Recent posts