Reputation: 9
I have this string: "7.0000000000000007E-2" (data.InnerText). I use the following code but this gave me the error: "Input string was not in a correct format.".
decimal value = Decimal.Parse(data.InnerText, CultureInfo.InvariantCulture);
I only need the number rounded on 2 decimals.
Upvotes: 1
Views: 1729
Reputation: 10272
If your culture uses . as the decimal separator :
double d = double.Parse("7.0000000000000007E-02");
Or try that way :
decimal d = Decimal.Parse("7.0000000000000007E-02", System.Globalization.NumberStyles.Float);
Upvotes: 2