David

David

  • NA
  • 5
  • 0

Try Catch Finally

Jul 21 2006 1:51 PM
Hi.

I was wondering if anybody could explain to me the purpose of the Finally block in exception handling. For example, what is the difference between these two pieces of code.

Example 1:

try
{
// open a file
}
catch (IOException ioe)
{
// log the error or something
}
finally
{
// do more stuff
}

Example 2:

try
{ // open a file
}
catch (IOException ioe)
{
// log the error or something
}
// do more stuff

Thanks,

Dave

Answers (3)