using System;
class MainClass
{
public static void Main()
{
int[] myArray = new int[2];
Console.WriteLine("Attempting to access an invalid array element");
myArray[2] = 1;
}
}
Output
Attempting to access an invalid array element
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at MainClass.Main()