是否有可能尝试块有4个捕获块? [英] is it possible a try block having 4 catch blocks ?

查看:121
本文介绍了是否有可能尝试块有4个捕获块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果try块有4个catch块,可以向整个catch块发出异常吗?

if a try block having 4 catch blocks, can fire exception to entire catch block ?

推荐答案

try{
}
catch(ExceptionType1 ex1)
{
}
catch(ExceptionType2 ex2)
{
}
...
catch(Exception ex)
{
}



如果没有任何异常类型与上一个匹配,则给出上述内容异常处理程序将捕获异常。


Given the above if none of the exception types match the the last exception handler will catch the exception.


是。它可能。



Yes. its possible.

try
{
    // Many types of exceptions can be thrown
}
catch (CustomException ce)
{
    ...
}
catch (AnotherCustomException ace)
{
    ...
}
catch (Exception ex)
{
    ...
}


这篇关于是否有可能尝试块有4个捕获块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆