In C#, can I have multiple type of exception within the same catch?
I just want to if its possible to do something like this, I appreciate any help
try
{
}
catch (ArgumentException || FormatException x)
{
// do something....
}
catch(Exception x)
{
throw;
}
>Solution :
hey can you can try this.
try
{
// do something....
}
catch(Exception ex)
{
if(ex is ArgumentException || ex is FormatException)
{
//do something
}
else
{
throw;
}
}