日期:2014-05-18 浏览次数:21317 次
button_click()
{
action1()
action2()
action3()
}
protected void button_click()
{
try
{
action1();
action2();
action3();
}
catch
{
// do nothing
}
}
void action1()
{
// Optional action ...
if (something happeded)
{
throw new Exception();
}
// Optional action ...
}
------解决方案--------------------
补充说明:因为在action1()action2()action3()中没有定义Try Block, 所以当异常发生时就会Trace到调用点,如果调用点在Try Block中,异常就会被捕捉,继续执行catch 以后的语句。
------解决方案--------------------
用 try - catch 捕获异常处理啊
当然 如果楼主所谓的‘没有正常执行’不是指会抛异常的错误的话 那就if..else就足够了
------解决方案--------------------
action1()
action2()
action3()
做成带返回值的方法,根据放回的值进行判断,如果满足退出条件就retrun
------解决方案--------------------
return
------解决方案--------------------
e.canel
------解决方案--------------------
用try
{}
catch()
{}
------解决方案--------------------
Return;
------解决方案--------------------
try
{action1()
}
catch {return
}
try
{action2()
}
catch {return
}
try
{action3()
}
catch {return
}
------解决方案--------------------
支持7楼!
------解决方案--------------------
Environment.Exit(0)来个重口味的