赞
踩
--在实际应用场景中,常常有这种情况,当我们程序出现异常时,这个异常不会造成什么不好的影响或者我们只是想把这个异常提示出来给操作的人看,这时出现异常时,程序后面的步骤也需要继续走下去解决方法可以用一个全局的try catch包起来
再在里面嵌套一个try catch finally,如下:
try
{
try
{
//将需要忽略的异常放到这一块
}
catch
{
//可选
}
finally
{
scph = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "shengchanhao").ToString();
xgsj = Convert.ToDateTime(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "xiaguidate")).ToString("yyyy-MM-dd HH:mm:ss.fff");
string _id1 = gridView1.GetFocusedRowCellValue("id").ToString();
_id = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "id").ToString();
dp_overtime.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "OverTime1").ToString();
cmbjiawei.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "jiawei").ToString();
txtSCH.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "shengchanhao").ToString();
txtNum.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Num").ToString();
txtBeiZhu.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "beizhu").ToString();
txtType.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Pro_type").ToString();
label13.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Num").ToString();
indate = Convert.ToDateTime(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "indate").ToString()).ToString("yyyy-MM-dd HH:mm:ss");
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.ToString());
}
--throw和 throw ex的区别是前者显示行号,明确那一行报错,后者不显示
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。