我已经在C#中构建了一个应用程序,在捕获异常后我必须中断应用程序。我使用return
,但它返回到调用此模块并继续执行的模块。应该做什么?异常处理后需要破解
我的代码看起来喜欢这样的:
class a
{
b bee=new b{};
bee.read(name);
bee.write(name);// don want this to get executed if exception is thrown
}
class b
{
read(string name)
{
try{}
catch
{
//caught;
//what should be put here so that it just stops after dialog
// box is shown without moving to the write method?
}
write(string name) {}
}
}
您的示例不正确,无法编译,请提供有效的代码示例 – Dyppl 2011-05-18 05:43:10
“break”是什么意思?应用程序应该退出吗?或者只是暂停一会儿? – Oded 2011-05-18 05:44:21
当异常被捕获时,是否要关闭整个应用程序? – Dyppl 2011-05-18 05:44:46