ExceptionHandling
Can we use multiple catch block for single try block in asp.net ? Please briefly Explain ...
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 4, 2015, 1:52 AM EST
If the code in the 'try' block can throw several different types of exception, then you can have multiple 'catch' blocks each of which deals with a different type of exception.
Pranay RanaRank #735 · 3.2K reputationPosted Feb 4, 2015, 1:58 AM EST
you can have multiple catch block , but you should have least exception block at last so you dont miss any unhandle excpetion
try
{
}
catch(FileNoFoundExcpetion ex)
{
}
catch(UnAuthorizeExcpetion ex)
{
}
catch(Exception ex) //general exception should be at last
{
}
Saber ShaikhRank #1,687 · 905 reputationPosted Feb 4, 2015, 2:06 AM EST
Saber ShaikhRank #1,687 · 905 reputationPosted Feb 4, 2015, 1:56 AM EST