Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Catch IndexOutOfRangeException Exception

using System;     class MainClass {     public static void Main()     {         try         {             int [] IntegerArray = new int [5];                 IntegerArray[10] = 123;         }         catch(IndexOutOfRangeException)         {             Console.WriteLine("An invalid element index access was attempted.");         }     } }