본문 바로가기

컴퓨터 과학 & 영상처리 관련/C# / .NET / JAVA

C#에서 printf("%03d",10)과 같은 번호 얻기

http://stackoverflow.com/questions/12570807/format-string-to-a-3-digit-number


17down voteaccepted

If you're just formatting a number, you can just provide the proper custom numeric format to make it a 3 digit string directly:

myString = 3.ToString("000");

Or, alternatively, use the standard D format string:

myString = 3.ToString("D3");