你为什么要使用指令删除不必要C#? [英] Why should you remove unnecessary C# using directives?
问题描述
例如,我很少需要:
using System.Text;
但它总是存在默认。我认为,如果你的code包含不必要的使用指令<应用程序将使用更多的内存/ A>。但是,还有什么我应该知道的?
but it's always there by default. I assume the application will use more memory if your code contains unnecessary using directives. But is there anything else I should be aware of?
此外,它使任何区别,如果任何与使用指令只在一个文件中使用与大多数/所有文件?
Also, does it make any difference whatsoever if the same using directive is used in only one file vs. most/all files?
的编辑:请注意,这个问题不是不相关的概念using语句称为一>,旨在帮助当对象超出范围,它的<一,确保管理资源href=\"http://msdn.microsoft.com/en-us/library/system.idisposable.dispose.aspx\">IDisposable.Dispose方法被调用。见用途使用在C#中的 的
Note that this question is not about the unrelated concept called a using statement, designed to help one manage resources by ensuring that when an object goes out of scope, its IDisposable.Dispose method is called. See Uses of "using" in C#.
推荐答案
你的程序运行时,它不会改变任何东西。这需要的一切按需加载。所以,即使你有using语句,除非你实际上是在该命名空间/装配使用类型,使用的语句是相关的将不会加载该程序集。
It won't change anything when your program runs. Everything that's needed is loaded on demand. So even if you have that using statement, unless you actually use a type in that namespace / assembly, the assembly that using statement is correlated to won't be loaded.
主要是,它只是清理个人preference。
Mainly, it's just to clean up for personal preference.
这篇关于你为什么要使用指令删除不必要C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!