일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Binding
- log
- chashtag
- Github
- ListView
- nullable
- Microsoft
- convert
- csharp
- coding-test
- Coding
- .net
- WPF
- tls
- algorithm
- IValueConverter
- git
- C#
- dotNET
- mysql
- windows10
- 코딩테스트
- windows
- logging
- string
- commit
- File
- programmers
- Visual Studio
- Process
Archives
- Today
- Total
CHashtag
[C#] 숫자 천단위 콤마찍기 (금액 표기하기) 본문
반응형
안녕하세요.
오늘은 내용이 짧으니 바로 본론으로 들어가 보겠습니다.
다양한 방법이 존재하는데요,
그 중 상황에 맞는걸 선택하시면 좋을 것 같습니다.
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
반응형
'C#' 카테고리의 다른 글
[C#] JWT 암호화, 복호화 예제 (0) | 2023.02.20 |
---|---|
[C#] bigint란 무엇이며, bigint는 무한한 값을 저장할 수 있을까? (1) | 2023.02.20 |
[C#] Extension Method 요청인자가 null일 때 NullReferenceException이 발생하지 않는 이유 (0) | 2023.01.17 |
[C#] SendKeys.Send() ArgumentException 문자열이 잘못되었습니다. 해결방법 (0) | 2022.11.30 |
[C#] IE기반 WebBrowser는 지원 중단되나? (0) | 2022.08.28 |