DebugBreak()等价于C# [英] DebugBreak() Equivalent in C#

查看:476
本文介绍了DebugBreak()等价于C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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:

< img src =https://i.stack.imgur.com/ZwenN.pngalt =断点右键菜单>

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

and then edit the condition to fit your needs:

然后,它将在您的断点点内用一个小的+进行符号化:

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

这篇关于DebugBreak()等价于C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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