Examveda

What will be the output of the following C# code?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 5; ++i) 
        Console.WriteLine(a[i]);
        int x = (1 / Convert.ToInt32(0));
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("A");        	
    }
    catch(ArithmeticException e) 
    {     	
        Console.WriteLine("B");
    }
    Console.ReadLine();
}

A. 1234

B. 12345

C. Run time error

D. 12345B

Answer: Option D


Join The Discussion

Related Questions on Exception Handling in C Sharp