我可以设置一个断点,当变量越来越.NET中一个特定的值? [英] Can I set a breakpoint when variable is getting a specific value in .NET?
问题描述
我在使用Visual Studio 2010,我也知道这个功能可在C ++。
I am using Visual Studio 2010, and I know this feature is available in C++.
我需要调试一些code,改变一个变量来几个值。我想在一个特定的情况下调试code,当变量得到一个特定的值。我知道我可以添加如果(VAR ==值)
,但没有任何优雅的方式来做到这一点?
I need to debug some code, that changes a variable to several values. I want to debug the code in a specific case, when the variable getting a specific value. I know I can add if(var == value)
, but is there any elegant way to do it?
还有一个问题,我可以设置一个断点,当变量一般是改变了吗?
Another question, can I set a breakpoint when a variable is changed in general?
推荐答案
这当然是可以设置像一个变量接收某个值的条件。这被称为断点条件。要创建一个,做到以下几点。
It is certainly possible to set a condition like a variable receiving a certain value. This is known as a breakpoint condition. To create one, do the following.
- 在该点设置一个破发点的变量的变化
- 右键点击破发点,并选择条件
- 在有条件喜欢的类型theNewValue == 42
现在的断点只命中,当你的条件计算结果为true。
Now the breakpoint will only hit when your conditional evaluates to true.
你问的第二个项目,当由于某种原因变量的值发生变化,被称为数据断点打破。这些只适用于C ++ code。这不是在C#中, VB.NET 或任何其他托管语言的选项。
The second item you asked for, breaking when a variables value changes for any reason, is known as a data breakpoint. These are only available for C++ code. It's not an option in C#, VB.NET or any other managed language.
这篇关于我可以设置一个断点,当变量越来越.NET中一个特定的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!