April 15, 2015

Exception in catch block

Consider below program if there will be exception inside catch block then what will be the output of this program?

static void Main()
        {
           
int A = 0;
           
int Y = 5;
           
int X = 0;

           
try
            {
                A = 0;
                Y = 5;
                X = Y / A;
            }

           
catch (Exception ex)
            {
                X = Y / A;
            }

           
finally
            {
               
Console.WriteLine("I am in finally block");
               
Console.ReadKey();
            }
        }


This program will generate run time exception and it will get terminated.

No comments:

Post a Comment