C# Compiler should give warning but doesn't?

后端 未结 7 1170
北恋
北恋 2020-12-03 14:05

Someone on my team tried fixing a \'variable not used\' warning in an empty catch clause.

try { ... } catch (Exception ex) { }

-> gives a w

7条回答
  •  醉话见心
    2020-12-03 14:43

    Properties are just methods, and there's nothing stopping anyone from putting some code that does something in the ex.Message property. Therefore, while you may not be doing anything with s, calling ex.Message COULD potentially have value....

提交回复
热议问题