未使用的及QUOT性能的影响;采用"在C#指令指令、性能、QUOT

2023-09-04 07:15:35 作者:我再难过也无须向你汇报

只是好奇。

它的问题,如果我在我的code文件的起点,我不会在我的code使用添加多个使用指令。就像这一点。

Does it matter if I add multiple using directives at the starting of my code file which I doesn't use in my code. Like this.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
//using blah.. blah.. blah..;

public class myClass
{
    // Class members
}

它是否对我的应用程序的内存使用情况不好的影响。

它是否对我的应用程序的业绩不好的影响

Does it has bad impact on my application's performance.

我知道这是一个很好的做法,除去他们,我们有短全力支持.NET IDE中这样做,但我只是好奇,想知道这一点。

I know it is a good practice to remove them and we have short full support of .Net IDE to do so, but I am just curious to know about it.

推荐答案

使用的指令的,不会对最终的任何内存/性能的影响应用程序 - 它们只是提供编译器的快捷方式来处理长期类型的名称。编译器使用这些命名空间来解析不合格的(或部分限定)类型名称更正类型。

Extra Using directives will not have any memory/performance impact on final application - they are nothing but compiler provided shortcuts to deal with long type names. Compiler uses these namespaces to resolve unqualified (or partly qualified) type names to correct types.