I’m quite unsure about using goto inside an using block.
For example:
using(stream s = new stream("blah blah blah"));
{
//do some stuff here
if(someCondition) goto myLabel;
}
Now if someCondition is true the code execution will move on to myLabel, but, will the the object get disposed?
I’ve seen some pretty good questions here on this topic but they all talk about different things.
The using statement is essentially a try-finally block and a dispose pattern wrapped up in one simple statement.
Is equivalent to
Thus, any jump from the “try-block”, be it throwing an exception, the use of goto (unclean!) &tc. will execute the Disposal of the object being used in that “finally” block..