using System;
class MainClass
{
public static void Main()
{
try
{
int[] intArray = new int[5];
for (int i = 0; i <= intArray.Length; i++)
{
intArray[i] = i;
Console.WriteLine("intArray[" + i + "] = " + intArray[i]);
}
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine("IndexOutOfRangeException occurred");
Console.WriteLine("Message = " + e.Message);
Console.WriteLine("Stack trace = " + e.StackTrace);
}
}
}
|