关于异常处理(try,catch和finally块) [英] Regarding Exception handling(try ,catch and finally blocks)

查看:104
本文介绍了关于异常处理(try,catch和finally块)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在try blcok中发生异常控件进入catch块,如果我已经在下面的catch块中编写代码

server.transfer(virtulapath)



将控制执行代码块(在catch块中)?如果是,那么如何


控制器知道最后是否阻止?

假设如果最终阻止那里。它会执行还是不执行?如果是,那么控制器

如何知道在导航到指定的虚拟路径后最终有阻塞?

Suppose exception occurs in try blcok the control goes to catch block, if i have written the code in catch block like below
server.transfer("virtulapath")

will control executes above code block (which is in catch block) ? if yes then how

controller knows there is finally block or not ?
suppose if finally block also there. will it execute or not? if yes then how controller
knows there is finally block after navigating to specified virtual path?

推荐答案

最后是一个将执行的块两个条件

如果异常被捕获或者如果没有最终将执行肯定

Ya ..如果异常被捕获则控制移动到catch块和你写的任何内容catch block将执行



for ex

try

{

} < br $>
catch

{

}

终于

{

Label1.text =完成;

}



这里是否发生异常label1将有文字Done

阅读更多尝试捕捉理论以更好地了解自己。
finally is a block which will execute in both conditions
If exception is caught or if not finally will execute for sure
Ya..if exception is caught then the control moves to catch block and whatever you have written in catch block will execute

for ex
try
{
}
catch
{
}
finally
{
Label1.text="Done";
}

Here whether exception occurs or not at the end label1 will have text "Done"
Read more try catch theory to understand yourself better.


这篇关于关于异常处理(try,catch和finally块)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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