I have the following number: 4.3
I\'d like to display this number as 4,3
for some of our European friends.
I was under the impressi
Yes, you are using the wrong string, and also the problem can't be solved by only providing a formatting string.
What your formatting string does is to format the number using the pattern "0"
, then aligned to the length 0
.
When you specify the decimal separator in a formatting string it's always a period regardless of the current culture. The decimal separator in the result of the formatting on the other hand is always the one used by the current culture. So, to get a comma as decimal separator in the result you have to make sure that the culture used for the formatting is one that uses comma as decimal separator.
You can either set the current culture for the thread so that it's used by default by the formatting, or specify a culture in the call:
string ret = String.Format(CultureInfo.GetCultureInfo(1053), "{0:0.0}", 4.3);