用户控制异常处理

时间:2013-11-23 15:58:50

标签: c# .net exception user-controls

问题

Okai,我有几个用户控件,我多次重复使用。例如,我有一个NumericUpDown控件,后面有一些代码,但我想捕获异常ArgumentOutOfRangeException,但我不知道如何......它也只会在我第一次更改值时触发,我的表单中有多个此控件的实例。

到目前为止我尝试了什么

private void num_ValueChanged(object sender, EventArgs e)
{
    try
    {
    }
    catch (Exception exception)
    {
        if (exception is ArgumentOutOfRangeException)
        {
        }
    }
}

1 个答案:

答案 0 :(得分:0)

只需列出所需异常的类型,而不是基本异常类。

try
{

}
catch (ArgumentOutOfRangeException exception)
{

}