加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 调试时是否可以完全忽略catch块?

发布时间:2020-12-15 06:43:08 所属栏目:百科 来源:网络整理
导读:我在WinForms(.net 3.5)中工作,并具有以下代码行: HitTestResult result; try { result = this.HitTest( e.X,e.Y,ChartElementType.DataPoint); } catch(Exception e) { //This happens,we don't care! } 我无法控制HitTest是否抛出异常,但如果是这样,我绝
我在WinForms(.net 3.5)中工作,并具有以下代码行:
HitTestResult result;
     try
     {
        result = this.HitTest( e.X,e.Y,ChartElementType.DataPoint);
     }
     catch(Exception e)
     {
        //This happens,we don't care!
     }

我无法控制HitTest是否抛出异常,但如果是这样,我绝对不在乎.

是否可以禁用我的IDE停止在这个SPECIFIC catch块?我明白我可以禁用它可能抛出的System.FormatException(从Debug->例外菜单,但这是一种过度的杀戮.

谢谢!

解决方法

您可以使用 DebbugerStepThrough属性跳过该行.从MSDN:

Instructs the debugger to step through the code instead of stepping
into the code.

例如:

[DebuggerStepThrough]
public void MyMethod()
{
    HitTestResult result;
    try
    {
        result = this.HitTest(e.X,ChartElementType.DataPoint);
    }
    catch (Exception e)
    {
        //This happens,we don't care!
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读