Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to save and load some values from xml file using c#.

I have the xml file data like this.
XML
<TEMPERATURE>
  <MIN>10,5</MIN>
  <MAX>150,0</MAX>
</TEMPERATURE>

I have some node like this
XML
<LIMITS>
    <TEMPMAX>150.0</TEMPMAX>
    <TEMPMAXPEAK>0.0</TEMPMAXPEAK>
    <TEMPMIN>0.0</TEMPMIN>
    <TEMPMINPEAK>10.0</TEMPMINPEAK>  
</LIMITS>


It is saving like that when i save to xml file. when i load from xml file i am able to get numeric format separated with cama (",") and assigning to double variable in my calculation using "double.parse" method and i am not getting any error. its working perfectly.

When i use same method (double.parse)for numeric format separated with (".") point then i am getting error like "input string format was incorrect".

Can anyone help me.
Posted
Comments
[no name] 23-Jul-13 9:17am    
Try using http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.invariantculture.aspx

1 solution

Have you tried replacing all the '.' inside with a ','. You can use a simple replace command.

C#
string str = "0.52";
str = str.ToString().Replace(".", ",");
 
Share this answer
 
Comments
PIEBALDconsult 23-Jul-13 9:44am    
Please don't use Replace for that.
vebi1000 23-Jul-13 10:27am    
Its working but is it the standard way! so that i can use like this whenever i need.
[no name] 23-Jul-13 14:10pm    
yes, and also why the down vote?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900