Skip to content

Latest commit

 

History

History
38 lines (34 loc) · 1.86 KB

File metadata and controls

38 lines (34 loc) · 1.86 KB
title try-catch-finally (C# Reference)
ms.date 07/20/2015
ms.prod .net
ms.technology
devlang-csharp
ms.topic article
f1_keywords
catch-finally_CSharpKeyword
catch-finally
helpviewer_keywords
finally blocks [C#]
try-catch statement [C#]
ms.assetid a1b443b0-ff7a-43ab-b835-0cc9bfbd15ca
caps.latest.revision 21
author BillWagner
ms.author wiwagn

try-catch-finally (C# Reference)

A common usage of catch and finally together is to obtain and use resources in a try block, deal with exceptional circumstances in a catch block, and release the resources in the finally block.

For more information and examples on re-throwing exceptions, see try-catch and Throwing Exceptions. For more information about the finally block, see try-finally.

Example

[!code-csharpcsrefKeywordsExceptions#1]

C# Language Specification

[!INCLUDECSharplangspec]

See Also

C# Reference
C# Programming Guide
C# Keywords
try, throw, and catch Statements (C++)
Exception Handling Statements
throw
How to: Explicitly Throw Exceptions
using Statement