adplus-dvertising
frame-decoration

Question

What will be the output of given code snippet?
{
    try 
    {
        int []a = {1, 2, 3, 4, 5};
        for (int i = 0; i < 7; ++i) 
        Console.WriteLine(a[i]);
    }
    catch(IndexOutOfRangeException e) 
    {
        Console.WriteLine("0");         
    }
    Console.ReadLine();
}

a.

12345

b.

123450

c.

1234500

d.

Compile time error

Posted under C# programming

Answer: (b).123450

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of given code snippet?