Language Basics C# Tutorial

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;
  }
}
Attempting to access an invalid array element
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
at MainClass.Main()