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

前端 未结 8 780
醉话见心
醉话见心 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:02

    If you want to catch variable change at some breakpoint, as opposed to catching exactly where it was changed, then set the breakpoint, right-click it and choose "Condition". Let's say your variable name is X and it's current value is A. Enter "X != A" in the condition field.

    Now the breakpoint will only be hit after X changes to some value other than A.

提交回复
热议问题