C#

[C#] 숫자에 콤마(Comma) 찍어보자

데브프로그라 2024. 2. 21. 21:52
반응형

숫자에 콤마와 원을 붙여 봅니다.

int nCost = 123456789;

string strCost = string.Format("{0:#,###}원", nCost);

Console.WriteLine(strCost);

출력: 123,456,789원

 

반응형

/* 코드복사 버튼 */ pre { position: relative; overflow: visible; } pre .copy-button { opacity: 0; position: absolute; right: 8px; top: 4px; padding: 6px 18px; color: rgb(255, 255, 255); background: rgba(255, 223, 0, 0.6); border-radius: 5px; transition: opacity .3s ease-in-out; } pre:hover .copy-button { opacity: 1; } pre .copy-button:hover { color: #eee; transition: all ease-in-out 0.3s; } pre .copy-button:active { color: #33f; transition: all ease-in-out 0.1s; } .copy-message:before { content: attr(copy-message); position: absolute; left: -95px; top: 0px; padding: 6px 18px; color: #fff; background: rgba(255, 223, 0, 0.6); border-radius: 5px; } /* 코드복사 버튼 END */