将 decimal 值转换为整型时,如果结果整数值在目标类型的范围以外,则会引发 OverflowException。最好捕获异常。
decimal d=2454765;
try
{
int iTemp=System.Convert.ToInt32(d);
}
catch(System.OverflowException e) {MessageBox.Show(e.Message);
}
decimal d=2454765;
try
{
int iTemp=System.Convert.ToInt32(d);
}
catch(System.OverflowException e) {MessageBox.Show(e.Message);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货