I have a line like the following in my code:
string buffer = string.Format(CultureInfo.InvariantCulture, "{0:N4}", 1008.0);
Why does buffer contain 1,008.0 (note comma) after executing this line?
Yes, I do guess that it’s caused by my regional settings. The question is why they affect the result in this case?
EDIT:
Ok, I understand that it’s completely my fault. It seems like I should have used F format specifier.
The
InvariantCultureis loosely based onen-USwhich uses,as a thousands (group) separator.Your result is what I would expect.
I also point you to the details of the
Nnumeric format specifier: