IndexOutOfRangeException Exception : Buildin Exceptions : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Buildin Exceptions »

 

IndexOutOfRangeException Exception








    

using System;
   
class MainClass
{
    public static void Main()
    {
        try
        {
            int [] IntegerArray = new int [5];
   
            IntegerArray[10] = 123;
   
            // wait for user to acknowledge the results
            Console.WriteLine("Hit Enter to terminate...");
            Console.Read();
        }
        catch(IndexOutOfRangeException)
        {
            Console.WriteLine("An invalid element index access was attempted.");
        }
    }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Buildin Exceptions