catch multiple exception c# code example
Example 1: c# multiple catch exceptions
// if C# v6+, you can use exception filters
catch (Exception ex) when (ex is FormatException || ex is OverflowException)
{
// do something
}
Example 2: catch multiple exception c#
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
return;
}
throw;
}
Example 3: c# catch two exceptions in one block
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
return;
}
throw;
}