Why to use "finally" block in c#?

Asked 01-Nov-2019
Viewed 674 times

1 Answer


0

Finally keyword is a reserved keyword in C#.Finally block executes when the try/catch block leaves the execution, no matter what condition caused it. It always executes whether the try block executes normally or without any exception.The main purpose of finally block is to release the system resources.
try

{
 //code
}
catch
{
 //code
}
finally
{
 //code
}