Answered by:
Is there any problem in using nested try catch

Question
-
hi experts,
Is there any problem in using nested try catch in c#
Monday, August 16, 2010 5:00 AM
Answers
-
Check below Discussion
http://stackoverflow.com/questions/663710/c-nested-try-catch-statements-or-methods
Please "Mark as Answer" if this post answered your question. :)
Kalpesh Chhatrala | Software Developer | Rajkot | India
Kalpesh 's Blog- Marked as answer by Figo Fei Wednesday, August 18, 2010 5:43 AM
Monday, August 16, 2010 5:26 AM -
Hello Luckyforu2006,
There is no problem in using the nested try catch in C# but thing need to remember is the order of the Catch block.
The correct order for Catch clauses when handling different exception types is that order must be from most specific to most general. The first type that matches is caught, and subsequent Catch clauses are skipped. Therefore, you should order Catch clauses from most specific to most general to enable you to catch errors that you have specific error-handling for, while still catching other exceptions with the more general Catch clauses.
Thanks,
Paras Sanghani
http://parassanghani.blogspot.com/
Mark As Answer if it helped you.
Monday, August 16, 2010 5:31 AM
All replies
-
Check below Discussion
http://stackoverflow.com/questions/663710/c-nested-try-catch-statements-or-methods
Please "Mark as Answer" if this post answered your question. :)
Kalpesh Chhatrala | Software Developer | Rajkot | India
Kalpesh 's Blog- Marked as answer by Figo Fei Wednesday, August 18, 2010 5:43 AM
Monday, August 16, 2010 5:26 AM -
Hello Luckyforu2006,
There is no problem in using the nested try catch in C# but thing need to remember is the order of the Catch block.
The correct order for Catch clauses when handling different exception types is that order must be from most specific to most general. The first type that matches is caught, and subsequent Catch clauses are skipped. Therefore, you should order Catch clauses from most specific to most general to enable you to catch errors that you have specific error-handling for, while still catching other exceptions with the more general Catch clauses.
Thanks,
Paras Sanghani
http://parassanghani.blogspot.com/
Mark As Answer if it helped you.
Monday, August 16, 2010 5:31 AM