在C#中有任何相当于DebugBreak()的声明。我想要在满足特定条件时调用调试器。
In C# is there any statement equivalent to DebugBreak(). I want to invoke the debugger when ever a particular condition is met.
请帮助
推荐答案您可以使用 Break 方法的 Debugger 类,在System.Diagnostics命名空间中:
You can use the Break method of the Debugger class, in the System.Diagnostics namespace:
Debugger.Break();现在,还有一种不同的方法可以添加条件断点,而不用添加代码到你的项目。
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:
更多推荐
DebugBreak()等价于C#
发布评论