Exception Filters

suggest change

Since C# 6.0, exceptions can be filtered with a when clause.

This is similar to a simple if inside the catch, but if the when condition is false the stack is not unwound and the exception can still be caught by an outer handler.

Example

try
{ 
  // ...
}
catch (Exception e) when (e.InnerException != null) // Any condition can go in here.
{
  // ...
}

The same info can be found in the C# 6.0 Features here: Exception filters

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents