Programming/C#

숫자 3자리마다 콤마(,) 찍기

blueasa 2014. 5. 13. 14:37

1. int won = 123456890;

2. Console.WriteLine(string.Format("{0:n0}", won));

3. Console.WriteLine(string.Format("{0}", won.ToString("n0"))); ;

4. Console.WriteLine(string.Format("{0:#,##0}", won));

5. Console.WriteLine(string.Format("{0}", won.ToString("#,##0")));

6.

7. //결과

8. //123,456,890

9. //123,456,890

10. //123,456,890

11. //123,456,890


스트링에다 .ToString("n0")를 시전하고 있었다... - _ -;....

스트링은 인트로 파스해서 변환해야하나...



출처 : http://ericstoltz.tistory.com/147


참조 : Standard Numeric Format Strings

반응형