Convert a string to number

Asked

Viewed 33 times

-1

I am reading in an excel file, but the values of them are coming in this format.

"-3,6379788070917E-12"

Code for conversion from string to decimal.

decimal.Parse(linha[5]);

When I do the error decimal conversion, saying the format is invalid. How can I turn this data into number?

  • Can you guarantee that this number is always valid? Where does it come from?

1 answer

2


You can use it as follows, showing that it is a float:

decimal d = Decimal.Parse("1.2345E-02", System.Globalization.NumberStyles.Float);
  • Thanks mzavarez it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.