的DebugBreak()相当于在C#DebugBreak

2023-09-03 02:22:44 作者:贱人永远喜欢贱人

在C#中有相当于的DebugBreak的陈述()。我想调用调试器当过特定条件得到满足。

In C# is there any statement equivalent to DebugBreak(). I want to invoke the debugger when ever a particular condition is met.

请帮忙

推荐答案

您可以使用的打破的调试类的方法,在System.Diagnostics命名空间:

You can use the Break method of the Debugger class, in the System.Diagnostics namespace:

Debugger.Break();

现在,还有一个不同的方式,您可以添加条件断点,无需摆弄增加code到项目中。

Now, there's also a different way you can add conditional breakpoints, without mucking about with adding code to your project.

这当然只有当已通过调试器中运行程序的工作原理的

你可以做的是先加一个普通断点,你希望你的调试器停止的位置,然后用鼠标右键单击红点断点:

What you can do is first add a regular breakpoint at the location where you want your debugger to stop, then right-click the red dot for the breakpoint:

,然后编辑条件,以满足您的需要:

and then edit the condition to fit your needs:

这将被符号化的小+断点点内:

This will then be symbolized with a small + inside your breakpoint dot:

相关推荐