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


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: