Freigeben über


Did you know... You can use the Watch Window to quickly change a variable's value - #149

And now for something a little different…

Ever been debugging some code and wanted to quickly change a variable’s value without having to stop debugging?  Here’s what to do…

  1. Add the value to the watch window (You can select the variable and drag it into the watch window as shown below). 
  2. Then, double-click the variable’s contents within the watch window, and you’ll be able to edit.  Either click outside this field or press enter to commit the change, and the variable will contain the new contents.

Dragging Variables into Watch Window

Commit changes to Watch Window by hitting enter

Contents have changed at run-time

If you need to clear the watch window’s variable contents, just hit delete on that row.

Technorati Tags: VS2005Tip,VS2008Tip

Comments

  • Anonymous
    February 11, 2008
    PingBack from http://msdnrss.thecoderblogs.com/2008/02/12/

  • Anonymous
    February 12, 2008
    I found you can do the same thing from hoving the mouse over a variable. You can change any primitive value in the object hierarchy displayed in the popup. So very handy!

  • Anonymous
    February 12, 2008
    wow... 150 tips.  And just like the Energizer bunny , Tip of the Day keeps going and going and going

  • Anonymous
    February 13, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com

  • Anonymous
    February 27, 2008
    Actually, this isn't even limited to primitives...  If you have an object instance in your watch you can actually create an instance right there just by typing 'new Whatever()'...  It's frickin amazing :)

  • Anonymous
    December 24, 2008
    本篇包括tip141-tip150 http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-15.html #141...