// . - 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
,并显示消息“输入字符串格式不正确”。
这是一个错误还是预期的行为?
答案 0 :(得分:3)
看看它上面的项目:
//# - 数字占位符。如果值为
您引用的文字是指用于将转换为字符串的格式字符串,例如
value.ToString("#.###.###");
它与.Parse()
方法无关。
答案 1 :(得分:2)
该评论在
中// Format strings that do not start with an alphabetic character, or that start
// with an alphabetic character followed by a non-digit, are called
// user-defined format strings. The following table describes the formatting
// characters that are supported in user defined format strings.
部分,所以说明float.ToString(...)
。