Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# catch multiple exception types

try
{
    /*  Try do something ... */
}
catch (Exception ex) when (ex is InvalidDataException || ex is ArgumentException)
{
    Console.WriteLine("a specific catch");
}
catch (Exception ex)
{
  Console.WriteLine("General catch");
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #catch #multiple #exception #types
ADD COMMENT
Topic
Name
3+2 =