0 votes
in C Sharp by (6.0k points)

Why to use “finally” block in C-Sharp?

1 Answer

0 votes
by (30.8k points)

Finally block will be executed irrespective of exception. So while executing the code in try block when exception is occurred, control is returned to catch block and at last finally block will be executed. So closing connection to database / releasing the file handlers can be kept in finally block.

Related questions

0 votes
asked Oct 18, 2019 in C Sharp by Robin (13.0k points)
0 votes
asked May 6, 2020 in C Sharp by SakshiSharma (30.8k points)
0 votes
0 votes
asked Feb 16, 2020 in C Sharp by rahuljain1 (6.0k points)
0 votes
asked Feb 16, 2020 in C Sharp by rahuljain1 (6.0k points)
...