logo
Учебник_ПОА

Finally Blocks

Code contained in a finally block is always executed, whether or not an exception occurs. Use the finally block to make sure resources are returned: for example, to make sure that a file is closed.

try

{

// Code to try here.

}

catch (SomeSpecificException ex)

{

// Code to handle exception here.

}

finally

{

// Code to execute after try (and possibly catch) here.

}