如何将变量添加到“监视”窗口 [英] How can I add variables to the Watch window

查看:1118
本文介绍了如何将变量添加到“监视”窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2008 Pro:
好​​!从定制部分中,我将监视,快速监视...的工具栏命令添加到了调试菜单,但是我想仔细观察一个变量。我们如何将其添加到手表?我突出显示它并尝试添加它,但是它被禁用了。我希望能够先向手表添加一些感兴趣的变量,然后开始调试程序。

Visual Studio 2008 Pro: Ok! from the Customize section I added the toolbar commands for Watch,QuickWatch,...to the Debug menu but I want to carefully watch one variable. How do we add it to the Watch? I highlight it and try to add it but it is disabled. I want to be able to first adding some variables of interest to the watch and then start debugging the program.

推荐答案

您将当您在调试器下运行并且暂停执行时,能够在监视模式下添加,查看和删除变量。进入这种状态的最简单方法:

You will be able to add, view and remove variables from the Watch Mode when you are running under the debugger and execution is paused. The easiest way to get into such a state:


  1. 在Visual Studio中打开项目

  2. 设置您要观看的变量范围内的代码中的断点。确保要执行的代码分支将被执行。

  3. 按F5或转到调试>开始调试

  4. 当断点为命中,可以通过以下任意一种方式将变量添加到监视窗口:

    • 右键单击代码中的变量,然后选择添加监视

    • 在本地窗口中右键单击变量,然后选择添加监视

    • 在监视窗格本身的新行中键入变量名称。

  1. Open your project in Visual Studio
  2. Set a breakpoint in the code within the scope of a variable you'd like to watch. Make sure that the code branch you're breaking on will be executed.
  3. Hit F5 or go to Debug > Start Debugging
  4. When the breakpoint is hit, add your variable to the watch window in any of the following ways:
    • Right click on the variable in code, and select "Add Watch"
    • Right click on the variable in the "Locals" windows, and select "Add Watch"
    • Type the variable name into a new row in the Watch pane itself.

之后,您应该在监视窗格中看到变量名称和值。在您逐步执行代码时以及暂停执行或遇到断点时,该值都会更新。

Afterwards, you should see the variable name and value in the watch pane. The value will be updated as you step through the code and any time you pause execution or hit a breakpoint.

这篇关于如何将变量添加到“监视”窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆