No.Catch block that handles the exception will get executed and all other catch will be skipped and then control goes to finally block if there is any and then to subsequent code after the finally block.
class A
{
static void Main(string[] args)
{
try
{
int a = 10;
int b = 0;
int i = a / b;
}
catch (DivideByZeroException)
{
Console.WriteLine("Inside Specialized Catch");
}
catch (Exception)
{
Console.WriteLine("Inside Generalized Catch");
}
finally
{
Console.WriteLine("Inside Finally");
}
Console.WriteLine("Outside try/catch/finally --- I got chance to Run");
}
}
No, Multiple catch blocks can't be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed.