String.Format() to add commas in thousands place for a number not working
String.Format
to add commas in thousands place just add space without comma.
I tried:
var total = string.Format("{0:n0}", 12345);
// expect: total = 12,345
// actual: total = 12 345
Anything I'm missing?
This is a culture thing. In your locale, space is the thousands specifier, apparently. I see commas. To see a specific locale's output, specify that explicitly. A very common option is "invariant":
var total = string.Format(CultureInfo.InvariantCulture, "{0:n0}", 12345);
This seems to be your regional settings on you PC:
The DEMO works fine
链接地址: http://www.djcxy.com/p/50548.html