Exception Handling

using System;
class Program
{
    public static void Main(String[] args)
    {
        int[] a = new int[4];
        for (int i = 0; i < 10; i++)
        {
            try
            {
                a[i] = i;
                Console.WriteLine(a[i]);
            }
            catch (IndexOutOfRangeException)
            {
                Console.WriteLine("Array Index out of Bounds");
            }
        }
    }
}

No comments:

Post a Comment