Go through the below code
Example:
try
{
//some code is executing..
//1.some SqlException thrown
//2.some FormatException thrown
//3. other Exception thrown
}
catch(SqlException sqlex)
{
Console.WriteLine("sqlexception is returned");
}
catch(FormatException fx)
{
Console.WriteLine("FormatException is returned");
}
catch(Exception ex)
{
Console.WriteLine("Mainexception is returned");
}
catch
{
Console.WriteLine("exception without any args is returned");
}
what might be the output of this, and why.?
which catch block will be executed at first and why?
If i declare catch(Exception ex)-immediately after the try block then it will not compile and gives an error for other catch blocks -"a previous catch clause catches all the exceptions" - so does this catch block with argument System.Exception acts as a master exception or main exception block..? if so why..?
Please advise and thanks for the help in advance.