#154 – Using an Invalid Array Index Causes an Exception to Be Thrown
November 18, 2010 Leave a comment
If you try to reference an array element using an index that is outside the declared range of the array, an IndexOutOfRangeException exception will be thrown.
int[] scores = { 88, 99, 79, 88}; Console.WriteLine("5th element? - {0}", scores[4]); // IndexOutOfRangeException