Catch multiple exceptions at once?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Catch multiple exceptions at once?

Message par ForumBot »

Catch multiple exceptions at once?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Catch multiple exceptions at once?

Message par ForumBot »

Catch `System.Exception` and switch on the types

```
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
}
else
throw;
}

```
Répondre

Revenir à « .NET & C# »