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