我有一个十进制解析的简单问题.以下代码在我的计算机上正常工作,但是当我在服务器上发布项目(VPS,Windows Server 2008 R2标准版)时,我收到错误"输入字符串的格式不正确".有什么想法有什么不对吗?
我将解析后的数字存储在MySQL数据库表中 - 列类型为 DECIMAL(10, 4)
源代码:
CultureInfo nonInvariantCulture = new CultureInfo("en-AU"); //or pl-PL
nonInvariantCulture.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = nonInvariantCulture;
string toConvert = ("3,4589").Replace(",", "."); //it's an example
decimal parsed = decimal.Parse(toConvert);
Run Code Online (Sandbox Code Playgroud)