简体   繁体   中英

How to set a breakpoint on a C# structure field in Visual Studio 2013

I've got the following structure:

public struct MyStruct
{
    public bool property1;
    public bool property2;
};

I would like to know how to break during debug when the value of property1 changes (without re-writing them as property with getter/setters, I can't do that)?

Any ideas?

These are fields, not properties. They are modified directly by other code so the only place where you could put a breakpoint is the code that modifies them.

What you can do, is create a conditional breakpoint that will break when a condition becomes true or a value changes. This is described in How to: Specify a Breakpoint Condition . Essentially, you right-click on a breakpoint and then click Condition from the shortcut menu.

This way you can put conditional breakpoints to any place that may modify the field. Again, you can't place the breakpoint on the field itself - it's just a memory location.

如果没有太多的地方写字段,我会在那里设置断点。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM