How would I separate thousands with space in C#

后端 未结 6 1495
温柔的废话
温柔的废话 2020-12-08 19:00

Assume I have the following decimal number that I have to format so that every thousand should be separated with a space:

 897.11 to 897.11
 1897.11 to 1 897         


        
6条回答
  •  清歌不尽
    2020-12-08 19:30

    try this

    int testNumber = 134566548;
    Console.WriteLine(string.Format("{0:N}", testNumber));
    

    You will received : 134 566 548,00

    Don't forget your culture.

提交回复
热议问题