Unused 'using' directives are not shown as warning, any valid reason?
Un开发者_运维技巧used 'using' directives are not shown as warning [C#], why is it so?
Is there any valid reason on this?
Eric Lippert talks about this in his blog post: Why are unused using directives not a warning?.
In summary it would cause lots of warnings that aren't really problems. The C# compiler tries to only warn you if there is actually a potential problem with the code. If there were too many unimportant warnings people would start to ignore them.
The automatic code generated by Visual Studio for example contains unused using
statements and it would be annoying if that generated warnings.
The compiler omptimises them away anyway so they have almost no impact on anything.
精彩评论