Set up dot instead of comma in numeric values

Ksice picture Ksice · Feb 6, 2012 · Viewed 93.8k times · Source

I have new XmlDocument object, i.g. xml is created during my program...

I want all numeric values in created xml was with dot symbol instead of comma by default.

Can I do something to declare it once, not to parse every decimal value?

I.e. To set up this dot instead of comma somewhere in the beginning and don't worry about this till the end?

Answer

bang picture bang · Feb 6, 2012

Try this:

System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";

System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;