If you run the code below it actually executes the finally after every call to the goto:
int i = 0;
Found:
i++;
try
{
throw new Exception();
}
catch (Exception)
{
goto Found;
}
finally
{
Console.Write("{0}\t", i);
}
Why?
Seems reasonable. A
finally
block is always run after either thetry
or thecatch
.Similarly
will always run the
finally
block. EDIT - but see Eric's comments above.That is the point of the
finally
block. It always executes (pretty much).