.net - 使用多个小数点分隔符进行解析

标签 .net parsing decimal-point

根据Reference Source :

// . - Decimal point. The first '.' character
// in the format string determines the location of the decimal separator in the
// formatted value; any additional '.' characters are ignored. The actual
// character used as a the decimal separator in the output string is given by
// the NumberFormatInfo used to format the number.

应使用第一个小数分隔符,随后的小数分隔符应被忽略。但是,下面的语句

float.Parse("1.000.000", new CultureInfo("en"))

抛出 FormatException 并显示消息“输入字符串的格式不正确”。

这是一个错误还是预期的行为?

最佳答案

查看上面的项目:

// # - Digit placeholder. If the value being

您引用的文本是指用于将转换为字符串的格式字符串,例如

 value.ToString("#.###.###");

它与 .Parse() 方法无关。

关于.net - 使用多个小数点分隔符进行解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35599803/

相关文章:

.net - 检查 WMI ManagementObject 查询是否为 Nothing 而不是使用 Try/Catch?

c# - 在 Web API 中调用 DELETE 方法

c++ - C++ 中的小数点 ('.' 是多少,我可以做一个吗?

c++ - 使用 setprecision 在 C++ 中舍入小数字段时出现问题

mysql - ORDER BY 数字的正确字段类型?

c# - 为什么不能在数组内交换匿名类型的属性?

c# - 数据关系插入和外键

php - 使用 PHP 解析 XML - 其中包括 & 符号和其他字符

android - 在 Android 上解析 SHOUTcast 7.html 元数据

javascript - 如何在 JavaScript 中使用 JSON.parse() 解析 HTML 字符串?