C# exception filter?

Since C# 6 you can now do this.

try { … }
catch (MyException e) when (myfilter(e))
{
    …
}

This is different from using an if statement from within the catch block, using exception filters will not unwind the stack.

Leave a Comment