需要将值转换为十进制

时间:2015-05-23 12:38:14

标签: numbers decimal converter

我有一个值" -3.23108510433268E-15"作为字符串格式。我需要将其转换为十进制值,但我在此

上收到错误
Decimal x = Convert.ToDecimal(cotVal);

cotVal= "-3.23108510433268E-15";

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

哪种语言? 在c#中你需要AllowLeadingSign

string s = "-3.23108510433268E-15";
        decimal dec = Decimal.Parse(s, NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign);