Can multiple catch blocks be executed?

No, once the proper catch code fires off, the control is transferred to the finally block (if there are any), and then whatever follows the finally block.

Showing Answers 1 - 3 of 3 Answers

yazhini

  • Dec 14th, 2005
 

No.Multiple catch blocks will not be executed. But, we can use multiple catch blocks for a try block.The respective catch block will get executed according to the error arises.

  Was this answer useful?  Yes

samiksc

  • Jan 9th, 2006
 

No: only one catch block will be executed for an exception.

We can write several catch blocks below a try block. When an exception generates all these catch blocks will be scanned sequentially for a matching exception type.

It is advised to write catch blocks with selective exceptions first and then a catch block for a general System.Exception. If we write catch (System.Exception ex) block as the first catch block rest blocks will not be scanned, because all exceptions will match System.Exception.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions