How do we check Array out of range error in C#

 Posted by Chvrsri on 1/25/2012 | Category: C# Interview questions | Views: 6231 | Points: 40
Answer:

In C# we have IndexOutOfRange exception which is used to check the index out of range exception.

Example:
try

{
------
}
catch(IndexOutOfRangeException ex)
{
Console.WriteLine("An index was out of range!");
}
catch(Exception ex)
{
Console.WriteLine("Error occured: " + ex.Message);
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response