开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜