如果您指定,它将起作用NumberStyles.Float:decimal x = decimal.Parse("1.2345E-02", NumberStyles.Float);Console.WriteLine(x); // Prints 0.012345我不能完全确定为什么默认情况下不支持此功能-默认值为use NumberStyles.Number,它使用AllowLeadingWhite,AllowTrailingWhite,AllowLeadingSign,AllowTrailingSign,AllowDecimalPoint和AllowThousands样式。可能与性能有关;我想指定一个指数是相对罕见的。
除了指定NumberStyles外,我还建议您使用decimal.TryParse函数,例如:decimal result;if( !decimal.TryParse("1.2345E-02", NumberStyles.Any, CultureInfo.InvariantCulture, out result) ){ // do something in case it fails?}作为NumberStyles的替代方法,只要确定格式,任何人都可以使用特定的集合。例如:NumberStyles.AllowExponent | NumberStyles.Float