LANGUAGE

try and catch

Runs a protected block and handles matching exceptions. Work and Recover are illustrative helpers.

Formal Syntax & Structure

csharp syntaxcsharp
try { Work(); } catch (InvalidOperationException) { Recover(); }

Working Example

Example Snippetcsharp
try { throw new InvalidOperationException(); } catch (InvalidOperationException) { Console.WriteLine("Failed"); }
C# & .NET Reference