gpt4 book ai didi

c# - 为什么在有效的双输入时收到 FormatException?

转载 作者:行者123 更新时间:2023-11-30 14:16:05 24 4
gpt4 key购买 nike

我收到 FormatException,我不知道为什么。

System.FormatException was unhandled by user code
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at System.Convert.ToDouble(String value)

代码行:

DELTA_BUY = Convert.ToDouble(parameters["DELTA_BUY"]);

值(来自调试窗口):

parameters["DELTA_BUY"] "0.0016"    string

upd 在一个执行路径上工作正常,但在另一执行路径上失败(当来自 WCF 时)。可在 double 上重现,适用于字符串。可能是格式/国家化问题?

最佳答案

您的机器是否可能设置为“0.0016”不是有效数字的文化?尝试

DELTA_BUY = Convert.ToDouble(parameters["DELTA_BUY"], System.Globalization.CultureInfo.InvariantCulture);

关于c# - 为什么在有效的双输入时收到 FormatException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8348317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com