I stumbled upon something like the following in our code base...
protected bool IsThing(object item)
{
try
{
return item is Thing;
}
catch (Exception)
{
return false;
}
}
I'm trying to work out if there is any circumstance in which this catch
will ever be visited?
The is
keyword never throws an exception.
That is a useless method and you should remove it.
if(IsThing(item)) {...}
could and should be replaced with if(item is Thing) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With