Why to use "finally" block in c#?

Asked 5 years ago
Viewed 770 times

0

Why to use "finally" block in c#?


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
}

answered 5 years ago by Shikhar Arora

Your Answer