[英]Convert to Different number to Decimals C# (scientific notation to decimal)
I was trying to convert following figure in to decimals but its throwing a error. 我试图将下面的数字转换为小数,但抛出错误。 could you please tell me how to change the format 你能告诉我如何更改格式吗
8.37E-08-05
(scientific notation) ====> 0.00000008372014000000
8.37E-08-05
(科学计数法)====> 0.00000008372014000000
var convertDecimal = Convert.ToDecimal("8.37E-08");
Error: Input string was not in a correct format. 错误:输入字符串的格式不正确。
first the string format should be something like 8.37E-08
and not 8.37E-08-05
. 首先,字符串格式应类似于8.37E-08
而不是8.37E-08-05
。
it's a floating point number. 这是一个浮点数。 you have to convert it as below 您必须将其转换如下
decimal d = decimal.Parse("8.37E-08", System.Globalization.NumberStyles.Float);
Thanks Sam 谢谢山姆
I use the same approach 我使用相同的方法
decimal convertDecimal = Decimal.Parse("8.37E-08", NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.