C#C
C#4y ago
surwren

Proper C multicatch syntax

I saw in Java that you can do multicatch blocks (see image)

I also looked it up on stackoverflow:

https://stackoverflow.com/questions/136035/catch-multiple-exceptions-at-once

However there seems to be several methods listed in the thread.

What's the c# convention for multicatch blocks?
Screenshot_20220905-183142.jpg
Stack Overflow
It is discouraged to simply catch System.Exception. Instead, only the "known" exceptions should be caught.
Now, this sometimes leads to unnecessary repetitive code, for example:
try
{
...
Was this page helpful?