c# – 如何自动重新引发异常
发布时间:2020-12-15 23:55:08 所属栏目:百科 来源:网络整理
导读:如果在try catch块中包装对HttpResponse.End的调用,则会自动重新引发ThreadAbortException.我假设即使你在try catch块中包装try catch块也是如此. 我怎样才能完成同样的事情?我没有这方面的实际应用程序. namespace Program{ class ReJoice { public void E
如果在try catch块中包装对HttpResponse.End的调用,则会自动重新引发ThreadAbortException.我假设即使你在try catch块中包装try catch块也是如此.
我怎样才能完成同样的事情?我没有这方面的实际应用程序. namespace Program { class ReJoice { public void End() //This does not automatically re-raise the exception if caught. { throw new Exception(); } } class Program { static void Main(string[] args) { try { ReJoice x = new ReJoice(); x.End(); } catch (Exception e) {} } } } 解决方法
您无法更改普通例外以获得此行为.
ThreadAbortException对此有特殊支持,您无法在C#中实现自己.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |