我在我的方法中有一个try/catch:
}
catch (OurCustomExceptionObject1 ex)
{
txtErrorMessage.InnerHtml = "test 1";
}
catch(OurCustomExceptionObject2 ex)
{
txtErrorMessage.InnerHtml = "test 2";
}
catch (OurCustomExceptionObject3 ex)
{
txtErrorMessage.InnerHtml = "test 3";
}
... rest of code here is being executed after the try/catch
Run Code Online (Sandbox Code Playgroud)
如果捕获到任何异常,我不希望其余代码运行.我正在处理异常.我听说出于某种原因不使用Exit Try.这是真的,这样做很糟糕吗?这是阻止执行代码后执行代码的正确方法吗?
Blu*_*eft 34
无论是return在catch块,重新抛出异常,或者代码从试块在try块下方移动.