Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up dot instead of comma in numeric values

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?

like image 875
Ksice Avatar asked Feb 06 '12 12:02

Ksice


People also ask

How do you change Number format from comma to dot in Excel?

Click File > Options. On the Advanced tab, under Editing options, clear the Use system separators check box. Type new separators in the Decimal separator and Thousands separator boxes.


2 Answers

Try this:

System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = ".";  System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; 
like image 122
bang Avatar answered Sep 20 '22 13:09

bang


You can use value.ToString(CultureInfo.InvariantCulture) to convert your numeric values to strings. Or you can globally change the current culture to a culture that uses the dot as the decimal separator:

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); 
like image 44
Thomas Levesque Avatar answered Sep 22 '22 13:09

Thomas Levesque