字符“23.00”转成int型!Input string was not in a correct format.

如何把字符“23.00”转成int型!
convert,parse,都抱错!
“Input   string   was   not   in   a   correct   format.”
------解决方案--------------------------------------------------------
如果需要考虑四舍五入可以先转成double
string s= "23.00 ";
double dTemp=double.Parse(s);
int iTemp=Convert.ToInt32(dTemp);
如果不需要,就可以用
string s = "23.00 ";
s = s.Substring(0,s.IndexOf( '. '));
int i = int.Parse(s);
posted @ 2012-02-06 17:40  Yaoquan.Luo  阅读(482)  评论(0编辑  收藏  举报