Exception handling for index outof range exception in c sharp.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Ass_45 { class Program { static void Main(string[] args) { int[] name = new int[3]; Console.WriteLine("Enter Array Value:"); try { for (int i = 0; i <= 3; i++) { name[i] = Convert.ToInt32(Console.ReadLine()); } for (int i = 0; i <= 3; i++) { Console.WriteLine("Array" + name[i]); } } catch (IndexOutOfRangeException) { Console.WriteLine("Array Out of Index Ha Ha Ha"); } finally { Console.ReadLine(); } } } }