当前位置: 代码迷 >> ASP.NET >> 为何类型转换总出错阿
  详细解决方案

为何类型转换总出错阿

热度:8779   发布时间:2013-02-25 00:00:00.0
为啥类型转换总出错阿

int temp2 = Convert.ToInt32 (gv.Rows[i].Cells[12+reccount].Text);
其中gv.Rows[i].Cells[12+reccount].text是数字,用convert或者parse 转换的时候,总是出错。

System.FormatException: Input string was not in a correct format.



------解决方案--------------------------------------------------------
几种常用的转换方式。。拿int型举例。。

Convert.ToInt32(); //将object类型转换为int型

int.Parse(); //将string型转换为int型

(int)... //一般的类型转换,比如将浮点型数据转成整型。。
  相关解决方案