开发者

How do I convert "1.20E+07" to a float?

开发者 https://www.devze.com 2023-03-14 04:37 出处:网络
I can\'t convert the text, \"1.20E开发者_如何学编程+07\" to a float. I\'ve tried: info = CultureInfo.GetCultureInfo (\"en-US\");

I can't convert the text, "1.20E开发者_如何学编程+07" to a float.

I've tried:

info = CultureInfo.GetCultureInfo ("en-US");
float.TryParse ("1.20E+07", NumberStyles.AllowExponent, info, out cellValue);


You must also allow for decimal points like this

float.TryParse ("1.20E+07", NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint, info, out cellValue);


Use NumberStyles.Float instead, and it works. I just tested it.


Try NumberStyles.Float.

(as documented under float.TryParse, by the way :) )


Even NumberStyles.Any worked for me

0

精彩评论

暂无评论...
验证码 换一张
取 消