Multiple Exception Analysis in C#
In this article We discuss on how to handle Multiple Exception Analysis in C# ( C-Sharp)
Multiple catch block enables the programmers to catch the exceptions and handling the same based on the type of exceptions thrown.
using System;
class VenkatClass
{
public static void Main()
{
int Val1 = 0;
int Ans = 0;
try
{
Ans= 100/Val1;
Console.WriteLine("This line wont get executed");
}
catch(DivideByZeroException ex)
{
Console.WriteLine("DivideByZeroException" );
}
catch(Exception ex1)
{
Console.WriteLine("Exception" );
}
finally
{
Console.WriteLine("Finally Block");
}
Console.WriteLine("Result is {0}",div);
}
}
The finally blocks gets executed by default irrespective of exceptions occured or not