I have a line of code for string formatting like below –
double dVal = Convert.ToDouble(args[0],
System.Globalization.CultureInfo.InvariantCulture);
string result = string.Format("{0}", dVal);
Now in other locales (like German and French), the result string contains “,” instead of “.” Which is expected behavior.
Is there something I could add by which I will maintain my double value with its “.” and not containing “,”?
You can modify the current NumberFormatInfo object to set the decimal seperator explicitely to the seperator of your needs.
Something like that should do the trick:
Note that you have to clone the
NumberFormatInfosince the properties are read-only.