try/finally

This lesson briefs over using try/finally block in C#.

We'll cover the following

Try/Finally Example

The try/finally block allows you to do the same as you learnt in the previous lessons, but instead, errors that are thrown are dealt with by the catch (if possible) and then thrown up the call stack.

Therefore, this example will still throw an exception since it doesn’t have a catch block.

Get hands-on with 1200+ tech skills courses.