在使用 C# 的 Visual Studio 2008 中,如何设置属性的监视?
在 Visual Studio 2008 中,我使用 C#(如果重要的话),如何在属性上设置监视,以便在执行期间每当值发生变化时我都能看到?
In Visual Studio 2008, I am using C# if that matters, how do I set a watch on a property so I see whenever the value changes during execution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您设置了断点,则可以右键单击“断点点”并选择“条件”。在这里您可以指定仅当某些值(您需要输入变量名称)更改时才命中断点。
当值发生变化时,“观察”值将显示为红色。
If you have set a breakpoint, then you can right-click on the "breakpoint dot" and select "Condition". Here you can specify that the breakpoint is only hit when some value (you need to type in the variable name) changes.
A "watched" value will show in red when the value changes.
在调试模式下设置断点,右键单击要分析的属性,然后单击“添加监视”。该值将显示在观察窗口中
In debug mode set a breakpoint, right click on the property you want to analyze and click "Add watch". The value will be shown in Watch window
您需要进入调试模式,因此如果您正在运行应用程序,请在调试模式下运行。否则,如果您正在运行 Web 服务,则需要附加到该进程(如 aspnet_wp.exe)。
然后,您应该在 Visual Studio 的底部有一个监视窗口,您可以在其中看到属性的值。 (您可以通过在其中一个空格中键入名称或单击“添加”来监视变量来获取此窗口中的属性)
最后一步是在程序中您想要查看变量的位置放置断点(停止点)您正在观看的价值。
You need to enter debug mode, so if you're running an application, run in debug. Otherwise, if you're running a web service, you need to attach to the process (like aspnet_wp.exe).
Then, you should have a watch window in the bottom of visual studio, where you can see the value of the property. (you get the property in this window by either typing the name in one of the spaces, or by clicking add to watch for the variable)
The last step is to place break points (stopping points) in your program where you want to see the value that you're watching.
在调试时,您可以右键单击任何变量并选择添加监视。您也可以拉出监视窗口并在名称栏中手动输入。我通常在程序开始时设置一个断点,这样我就可以添加监视,而且下次调试项目时它们应该在那里,这样您就不必每次都这样做。
While you are debugging you can right click on any variable and choose add watch. Also you can pull up the watch window and manually type it in the name column. I usually set a breakpoint at the start of my program so I can add watches, also they should be there the next time you debug project so you don't have to do it each time.