Will the following code compile (as part of a method):
 
string[] str = new string[5]; 
try 
{ 
     str[4] = "anything"; 
} 
catch (Exception e) 
{ 
     Console.WriteLine(e.Message); 
} 
catch (IndexOutOfRangeException e) 
{ 
     Console.WriteLine(e.Message); 
}
 
Explanation
Code will not compile.
Exception handling must be in ascending order through the hierarchy of exceptions (from classes-children to superclasses).
C#
C# Quiz
Learn C# Online

or Read more about C# Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback