c# - How to convert this scientific notation to decimal? -


after search in google, using below code still can not compiled

decimal h = convert.todecimal("2.09550901805872e-05");    decimal h2 = decimal.parse("2.09550901805872e-05", system.globalization.numberstyles.allowexponent); 

you have add numberstyles.allowdecimalpoint too:

decimal.parse("2.09550901805872e-05", numberstyles.allowexponent | numberstyles.allowdecimalpoint); 

msdn clear that:

indicates numeric string can in exponential notation. allowexponent flag allows parsed string contain exponent begins "e" or "e" character , followed optional positive or negative sign , integer. in other words, parses strings in form nnnexx, nnne+xx, , nnne-xx. it not allow decimal separator or sign in significand or mantissa; allow these elements in string parsed, use allowdecimalpoint , allowleadingsign flags, or use composite style includes these individual flags.


Comments

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -