multithreading - 在多线程中解析时,输入字符串的格式不正确

标签 multithreading visual-studio c#-4.0

有人能解释一下吗?

解析“55.01”时如何引发异常?我使用多线程。

- 编辑 -
但是...有时候可以

这个事实使我难过;(
我使用.NET 4.0和VS2010。

-编辑2 ---

好的,我取得了一些进展。当我不使用多线程时,一切都会完美无缺。但是,当我使用多线程(可能)时,线程之一将抛出FormatException,如图所示。

最佳答案

该系统可能是为某些期望以逗号作为小数点的区域性设置的。

http://msdn.microsoft.com/en-us/library/fd84bdyt.aspx:

The s parameter is interpreted using the formatting information in a NumberFormatInfo object that is initialized for the current thread culture. For more information, see CurrentInfo. To parse a string using the formatting information of some other culture, call the Double.Parse(String, IFormatProvider) or Double.Parse(String, NumberStyles, IFormatProvider) method.

关于multithreading - 在多线程中解析时,输入字符串的格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8690834/

相关文章:

visual-studio - 在 Visual Studio 2008 中折叠值/函数定义 (F#) 的任何方法?

visual-studio - 在 Visual Studio 中查找和替换不替换所有事件

c# - 使用 lambda 表达式的嵌套集合创建对象图

C# 3.5 winforms app升级到C#4.0 排除CAS问题

c++ - 如何从自身加入 std::thread(在 C++11 中)

java - 线程数组的最佳实践 (java)

multithreading - 同时将相同的可变函数应用于同一Vec的不同元素

c++ - 在 C/C++ 中使用多核支持

c# - 我想要类似 switch 语句的东西(但当然不同)

c - 为什么使用不同的循环会得到不同的输出?