0

Can we execute multiple catch blocks in C# ?

Exception Management

30th Mar 2020, 6:50 PM
Cihat
Cihat - avatar
4 ответов
+ 2
Aguilar , Yes. Only one will be executed. You are correct. Just to be sure you can read this answer: https://stackoverflow.com/questions/12583487/execution-of-multiple-catch-blocks
31st Mar 2020, 2:37 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
The Question was Challenge and it's answer was No, i suppose the point of question is like that; yeah u can write multiple catch blocks but just one of them can execute and handle the exception.
30th Mar 2020, 7:10 PM
Cihat
Cihat - avatar
0
Yes. In a try block there maybe more than one statement that are likely to throw exception. So you can associate multipe catch blocks with single try block. This lesson shows the same.(On third page) https://www.sololearn.com/learn/CSharp/2690/?ref=app
30th Mar 2020, 6:53 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
0
I just got this question. It is not very clear. I think that it should be removed. Too ambiguous. I found an SO post where multiple catch blocks will be ran. Of course they are nested. But defintily two will run. https://stackoverflow.com/questions/4035477/can-i-execute-multiple-catch-blocks
8th Jan 2021, 2:53 AM
Javadev