Explore BrainMass

C# console application to handle indexoutofrange exception.

Write a C# console application in which you declare an array of five integers and store five values in the array. Write a try block in which you place a loop that attempts to access each element of the array, incrementing a subscript from 0 to 10. Create a catch block that catches the eventual IndexOutOfRangeException; within the block, display "Now you've gone beyond the bounds of the array" on the screen.

Solution Preview

Please find below the solution. Kindly let me know if you have any confusion or any further questions on this.

Don't forget to leave a positive feedback along with a good rating and, restrict the postings to me in future if you like the work.


(Please use the code provided only ...

Solution Summary

The solution contains a properly written program which displays how to catch an exception when code tries to access an invalid array item. The code included is very easy to understand and follows all the proper coding guidelines.