我有这行代码:
return (this.pretWithoutDiscount / Double.Parse(UtilsStatic.getEuroValue())).ToString("N2") + "€";
Run Code Online (Sandbox Code Playgroud)
在调试模式中,我已经测试过,值是:
UtilsStatic.getEuroValue()="4.1878"
this.pretWithoutDiscount = 111.0
任何人都可以解释为什么:
Double.Parse(UtilsStatic.getEuroValue())= 41878.0
什么时候应该是4.1878 ??
谢谢...
PS:UtilsStatic.getEuroValue返回一个字符串.
你使用什么十进制seprator,我的猜测是','.尝试
Double.Parse(UtilsStatic.getEuroValue(),
System.Globalization.CultureInfo.InvariantCulture)
Run Code Online (Sandbox Code Playgroud)
这将使用'.'解析数字.作为小数点分隔符.