LANGUAGE
Exception filter
Selects a catch based on an additional Boolean condition. Variables and helpers are illustrative.
Formal Syntax & Structure
csharp syntaxcsharp
catch (InvalidOperationException) when (canRecover) { Recover(); }Working Example
Example Snippetcsharp
try { Work(); } catch (InvalidOperationException) when (canRecover) { Recover(); }