Visual Studio - 不同的断点集 [英] Visual Studio - different sets of breakpoints

查看:29
本文介绍了Visual Studio - 不同的断点集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio(2015 及更新版本)中,是否可以有多组断点?我有几个场景,我需要调试,但对于每个场景,我都希望有不同的断点集.手动启用/禁用它们非常耗时.

In Visual Studio (2015 and newer), is it possible to have multiple sets of breakpoins? I have several scenarios, I need to debug, but for each of them I would like to have different set of breakpoints. It is quite time-consuming to enable/disable them manually.

推荐答案

您可以从断点窗口导出和导入断点,然后根据需要导入它们.

You can export and import breakpoints from the breakpoints window and then import them as required.

或者,如果您不介意修改代码,您可以使用条件断点并在代码中设置条件.例如,设置一个布尔值 testingScenario1 = true,然后在断点上设置断点条件,以仅在 testingScenario1 == true 时中断.

Alternatively, if you don't mind modifying your code, you can use conditional breakpoints and set the condition in your code. E.g., set a boolean testingScenario1 = true and then set a breakpoint condition on the breakpoint to only break when testingScenario1 == true.

或者使用Debugger.Break().类似的东西:

Or use Debugger.Break(). Something like:

#if DEBUG
    if (testingScenario1)
        Debugger.Break();
#endif

这篇关于Visual Studio - 不同的断点集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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