我已經在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