How do I convert "1.20E+07" to a float?
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
精彩评论