How would I separate thousands with space in C#

后端 未结 6 1496
温柔的废话
温柔的废话 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:33

    Norwegian locale uses spaces as a separator, so if you were designing a website or application specifically for Norwegians, then you could use:

    (123897.11).ToString("n",new CultureInfo("nb-NO"))
    

    Which results in

    "123 897,11"
    

    Obviously, if you're not writing an application for the Norwegian market, then this would be a silly solution.

提交回复
热议问题