Javatpoint Logo
Javatpoint Logo

C# finally

C# finally block is used to execute important code which is to be executed whether exception is handled or not. It must be preceded by catch or try block.

C# finally example if exception is handled

Output:

System.DivideByZeroException: Attempted to divide by zero.
Finally block is executed
Rest of the code

C# finally example if exception is not handled

Output:

Unhandled Exception: System.DivideBy




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA