catch 2 exception in same line in c# code example
Example 1: two exceptions same catch c#
try
{
// Code
}
catch (Exception ex) when (ex is ArbitraryType1 || ex is ArbitraryType2)
{
throw;
}
Example 2: c# catch two exceptions in one block
catch (Exception ex)
{
if (ex is FormatException || ex is OverflowException)
{
WebId = Guid.Empty;
return;
}
throw;
}