C#
[C#] 숫자 천단위 콤마찍기 (금액 표기하기)
HyoSeong
2023. 1. 24. 22:13
반응형
안녕하세요.
오늘은 내용이 짧으니 바로 본론으로 들어가 보겠습니다.
다양한 방법이 존재하는데요,
그 중 상황에 맞는걸 선택하시면 좋을 것 같습니다.
using System.Globalization;
int number = 100000000;
Console.WriteLine(string.Format("{0:n0}", number)); // 100,000,000
Console.WriteLine(number.ToString("N0", new CultureInfo("ko-KR"))); // 100,000,000
Console.WriteLine(number.ToString("#,#", new CultureInfo("ko-KR"))); // 100,000,000
Console.WriteLine(string.Format("{0:#,##0.##}", number)); // 100,000,000
감사합니다.
.NET String.Format() to add commas in thousands place for a number
I want to add a comma in the thousands place for a number. Would String.Format() be the correct path to take? What format would I use?
stackoverflow.com
반응형