Visual Studio对无用引用(unused using)的处理方法

以前以为添加到代码中的using都会被编译器编译,其实是不对的,微软有这样一段解释:

Visual Studio notices when your code doesn’t use all of the libraries your
project references, and automatically omits references to any unused
libraries. This makes your binary slightly smaller than it would be if
unnecessary references were left in.

翻译过来就是Visual Studio会自动忽略未使用的using,即使有未使用的using,它们也不会被编译,最终也不会出现在exe或者dll中。

不过建议Code完之后还是自动清除一下未使用的using,既然未使用,放在那里岂不成了多余的了,删掉的话会使代码变得简洁一些。

posted on 2012-02-22 10:53  胡茂晓  阅读(728)  评论(0编辑  收藏  举报

导航