什么格式双必须? [英] What format double must be?
本文介绍了什么格式双必须?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试添加到double类型的List元素:
I try add to double type List element:
CurrentValues.Add(double.Parse(name.InnerText)); //15.9933
但我收到错误:
{输入字符串无效。}
name.InnerText必须是什么格式?
谢谢
But i get error:
{"Input string was invalid."}
What format name.InnerText must be?
Thank you
推荐答案
只需尝试相反的方法,看看结果如何:
Just try the other way around to see what the result is:
String.Format("{0}", 15.9933)
祝你好运!
Good luck!
取决于 - 机会是InnerText属性包含一些包装器信息(可能是HTML,但不知道它是什么控件,我无法分辨) - 所以请改用Text属性!
Depends - the chances are that the InnerText property contains some wrapper information (possibly HTML but without knowing what control it is I can''t tell) - so use the Text property instead!
假设CurrentValues类似于
Assuming that CurrentValues are something like
List<double> CurrentValues = new List<double></double></double>
您可能有小数位错误,所以你可以使用不变的文化内容:
You could have a decimal place wrong, so you could use invariant culture insead:
double.Parse(name.InnerText, CultureInfo.InvariantCulture)
您还应检查InnerText是否为空。
You should also check to see if InnerText is not empty.
这篇关于什么格式双必须?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文