This was tip #20 in my TechEd VS 2008 IDE tips and tricks talk.
When you want to do more than just edit the value of a variable, you can rewrite entire functions or create new ones in the immeidate window. I found this especially useful when I was doing the math to automate dragging a tool window from a docked location to a docking target. I basically had to do the math to calculate a straight line between the two points in order to send the coordinates to the mouse drag functions. If i did the math wrong, i could pull up the immediate window and play with the calculations over and over again without interfering with the main debugger, meaning that the variables and state of the main debugger would remain the same unless i purposefully modified a value in the immediate window.
A very simple example: let’s say that you have the basic “hello world” console app, but want to print out the result of some calculation. Notice how the console app just has “hello world”
If i put a breakpoint at the very end of this simple console app, i can bring up the immediate window via Debug – Windows – Immediate and do whatever i need. Let’s say i needed to use the immediate window as a glorified calculator, i can figure out the value of 1+1, as shown below in VB
Since we’re in a console application, you can even have the value of ‘i’ printed to the console window via the immediate window. This is where you actually want to change the state of your debugger.
and now the value of 2 appears in the console window.