LANGUAGE

finally block

Runs cleanup when control leaves the try under normal execution and ordinary exception unwinding.

Formal Syntax & Structure

csharp syntaxcsharp
try { Work(); } finally { Cleanup(); }

Working Example

Example Snippetcsharp
try { Console.WriteLine("Work"); } finally { Console.WriteLine("Cleanup"); }
C# & .NET Reference