using System; namespace CuriousTabConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int val = 55; int[] a = new int[5]; try { Console.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(FormatException e) { Console.Write("Bad Format "); } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program "); } } }
using System; namespace CuriousTabConsoleApplication { class MyProgram { static void Main (string[] args) { int index; int val = 66; int[] a = new int[5]; try { Consote.Write("Enter a number: "); index = Convert.ToInt32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred "); } Console.Write("Remaining program "); } } }
using System; namespace CuriousTabConsoleApplication { class MyProgram { static void Main(string[] args) { int index; int vat = 88; int[] a = new int(5]; try { Console.Write("Enter a number: "); index = Convert.Toint32(Console.ReadLine()); a[index] = val; } catch(Exception e) { Console.Write("Exception occurred"); } Console.Write("Remaining program"); } } }
using System; namespace CuriousTabConsoleApplication { class MyProgram { static void Main(string[] args) { int index = 6; int val = 44; int[] a = new int[5]; try { a[index] = val ; } catch(IndexOutOfRangeException e) { Console.Write("Index out of bounds "); } Console.Write("Remaining program"); } } }
Copyright ©CuriousTab. All rights reserved.