How do you start a new session? Like if I was to type in
How do I clear "a" and the rest of the variables from the scope?Code:Class a = new Class1();
Printable View
How do you start a new session? Like if I was to type in
How do I clear "a" and the rest of the variables from the scope?Code:Class a = new Class1();
To clear your class you can simply type
Beware that even though you've 'nullified' it, it won't be really gone until the garbage collector has disposed of it. That won't be a problem for your application though.Code:a = null;
But what do you mean with 'start a new session'?
I believe he means to close the current scope and open a new one. In normal code you declare a variable and it exists only within the block it's declared in. Once that block ends the variable ceases to exist. In the case of the Immediate window I don't believe that there's any way to force a variable that you've declared out of scope. I've never seen it done and I couldn't find any indication that it's possible in my own reading. That doesn't mean that it's not possible but they've hidden it pretty well if it is.
Interestingly, I wonder what happens if you declare a variable in the Immediate window and then a variable with the same name comes into scope as you step through your code. If you get the value of the variable with that name, which one will you get. Might check that out tomorrow, or today as it's 12:42 AM. Best off to sleeps.
Hm, Building the project (even if it is up to date) seems to do it. Although hoping there is a better way.