Once I've created a variable in the immediate window in C# (VS2008), is there any way to delete it so I can create a new variable with the same name but a different type? Apart from restarting the program that is.
The reason would be to keep the immediate window's namespace clean, since it's difficult to keep track of variable declarations once they scroll off the visible part of the window.
Working With Variables To view the variable's value, simply type its name into the immediate window and press Enter. The value, "Hello world" will be displayed beneath the typed line, as in the image above. To access properties of a variable or value, use the member access operator (.) as you would within source code.
To display the Immediate window, open a project for editing, and then choose Debug > Windows > Immediate or press Ctrl+Alt+I. You can also enter Debug. Immediate in the Command window. The Immediate window supports IntelliSense.
so you cannot “delete” variables, you can only change their value.
I don't think it is possible to do what you are asking.
You could make a dictionary to hold your immediate window "variables". Then you can remove items from the dictionary when you're done with them.
If you just want to keep namespace clean, you can use object instead of the types you've declared for the variable? But, don't know if there exists any method to clear them!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With