c#中的数字格式。 [英] Numeric format in c#.

查看:64
本文介绍了c#中的数字格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在尝试使用c#从xml文件中保存并加载一些值。



我有这样的xml文件数据。

Hi,

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

I have the xml file data like this.

<TEMPERATURE>
  <MIN>10,5</MIN>
  <MAX>150,0</MAX>
</TEMPERATURE>



我有一些这样的节点


I have some node like this

<LIMITS>
    <TEMPMAX>150.0</TEMPMAX>
    <TEMPMAXPEAK>0.0</TEMPMAXPEAK>
    <TEMPMIN>0.0</TEMPMIN>
    <TEMPMINPEAK>10.0</TEMPMINPEAK>  
</LIMITS>





就像这样保存当我保存到xml文件。当我从xml文件加载时,我能够得到用cama(,)分隔的数字格式,并在我的计算中使用double.parse方法分配给double变量,我没有收到任何错误。它工作得很好。



当我使用相同的方法(double.parse)用数字格式分隔(。)点时,我得到的错误就像输入字符串格式不正确。



任何人都可以帮助我。



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.

推荐答案

你试过替换所有' ''里面有','。您可以使用简单的替换命令。



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

string str = "0.52";
str = str.ToString().Replace(".", ",");


这篇关于c#中的数字格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆