VS2019调试时自动改变变量值?
In VS2019, automatically change variable value while debugging?
我有一个 If
声明,如下所示:
if (condition1 == "True" && condition2 == "True" && condition3 == "True" && condition4 == "True")
无需在调试期间更改每个值,是否可以在断点命中时自动将 condition1
的值更改为 condition4
为“True”?
我只想让调试器输入 If
语句,即使不满足条件。一旦 If
语句命中,编辑每个值是一件很痛苦的事。
最简单的解决方案很可能是在调试时 Change the execution flow。
With the debugger paused on a line of code, use the mouse to grab the yellow arrow pointer on the left. Move the yellow arrow pointer to a different point in the code execution path. Then you use F5 or a step command to continue running the app.
By changing the execution flow, you can do things like test different code execution paths or rerun code without restarting the debugger.
这使您能够在 if-statement 上设置断点,并在必要时将执行拖到 if
中。这样你甚至不必更改变量,但你可以简单地决定在 if-statement 中执行语句,只要你想测试它们。
或者,查看如何 Observe a single variable or expression with QuickWatch 并更改那里的变量值。
我有一个 If
声明,如下所示:
if (condition1 == "True" && condition2 == "True" && condition3 == "True" && condition4 == "True")
无需在调试期间更改每个值,是否可以在断点命中时自动将 condition1
的值更改为 condition4
为“True”?
我只想让调试器输入 If
语句,即使不满足条件。一旦 If
语句命中,编辑每个值是一件很痛苦的事。
最简单的解决方案很可能是在调试时 Change the execution flow。
With the debugger paused on a line of code, use the mouse to grab the yellow arrow pointer on the left. Move the yellow arrow pointer to a different point in the code execution path. Then you use F5 or a step command to continue running the app.
By changing the execution flow, you can do things like test different code execution paths or rerun code without restarting the debugger.
这使您能够在 if-statement 上设置断点,并在必要时将执行拖到 if
中。这样你甚至不必更改变量,但你可以简单地决定在 if-statement 中执行语句,只要你想测试它们。
或者,查看如何 Observe a single variable or expression with QuickWatch 并更改那里的变量值。