有人能解释一下吗?
解析“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/