报错:未处理FormatException Input string was not in a correct format.

hailun 2011-11-23 09:11:25
Convert.ToInt32(jg) > txtJg1
jg转换前为44.32
txtJg1为0
报错:未处理FormatException
Input string was not in a correct format.

int.parse(jg) > txtJg1
也是报上面的错

jg是从网页获取的String类型的
txtJG1是取的从TextBox.Text给定的值
...全文
157 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
MKing0412 2011-11-23
  • 打赏
  • 举报
回复
如果是int eg string str="44";
double db = Convert.ToDouble(str2);//db值为44.0 不影响下面转int
hailun 2011-11-23
  • 打赏
  • 举报
回复
但str2是随机的,可能是1
1,2,3,4,5.6,4.4这样的整 数和小数随机的,说不定是什么类型的
MKing0412 2011-11-23
  • 打赏
  • 举报
回复

string str2 = "44.32";
double db = Convert.ToDouble(str2);
int i = Convert.ToInt32(db);

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧