The variable 'MyException' is declared but never used

前端 未结 6 1990
迷失自我
迷失自我 2020-12-05 09:36

I need to clear this warning :

try
{
    doSomething()
}
catch (AmbiguousMatchException MyException)
{
    doSomethingElse()
}

The complier

6条回答
  •  清歌不尽
    2020-12-05 09:58

    but never used means that you should use it after catch() such as writing its value to console, then this warning message will disappear.

    catch (AmbiguousMatchException MyException)
    {
        Console.WriteLine(MyException); // use it here
    }
    

提交回复
热议问题