当变量在.NET中获得特定值时,可以设置断点吗? [英] Can I set a breakpoint when variable is getting a specific value in .NET?

查看:114
本文介绍了当变量在.NET中获得特定值时,可以设置断点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Visual Studio 2010,我知道这个功能在C ++中可用。

I am using Visual Studio 2010, and I know this feature is available in C++.

我需要调试一些代码,将一个变量更改为几个值。我想在一个特定的情况下调试代码,当变量获得一个特定的值。我知道我可以添加 if(var == value),但是有没有什么优雅的方式呢?

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.


  • 在变量更改点设置一个断点

  • 右键单击断点,然后选择条件

  • 键入条件,如newNewValue == 42

现在,当您的条件求值为true时,断点只会触发。

Now the breakpoint will only hit when your conditional evaluates to true.

您要求的第二个项目,当变量值为原因,被称为数据断点。这些仅适用于C ++代码。这不是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屋!

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