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?
Why do you expect it to not execute?
If you have try/catch/finally or try/finally block, finally block executes
no matter what code you may have in the try or catch blockmost of the time.Instead of goto, consider ‘return’.