How do I “run until this variable changes” when debugging?

前端 未结 8 778
醉话见心
醉话见心 2020-12-30 23:29

When debugging my C#, I often want to know when a variable\'s value changes and then investigate the state of the program.

Currently, I do

相关标签:
8条回答
  • 2020-12-31 00:07
    1. Set the breakpoint where you want the code to pause
    2. Open the Breakpoints window (Debug -> Windows -> Breakpoints)
    3. Right-click on your breakpoint and select Condition...
    4. Set the condition to be the variable name, and select the Has Changed radio button.
    5. Click OK, and then debug as per normal :)
    0 讨论(0)
  • 2020-12-31 00:09

    Conditional breakpoints are what you're after, but it appears they are not available in Visual Studio Express.

    In Visual Studio (non-Express), the way it works is that you create a conditional breakpoint with an expression equal to your watch value and "Has changed" as your breakpoint condition.

    0 讨论(0)
提交回复
热议问题