2013-07-17 26 views

回答

2

簡短的回答是NO,它不會增加「應用程序負載」

The C# Team's answers to frequently asked questions:

當您添加程序集的引用或使用'使用'關鍵字, csc.exe將忽略在您的代碼中實際上未使用的任何程序集 。因此,如果你要設置爲 System.Data.dll中和System.Windows.Forms.dll的參考,但僅創作了 下面的代碼:

using System; 
using System.Data; // Ignored. 
using System.Windows.Forms; // Ignored. 

public class MyClass 
{ 
    public static void Main() 
    { 
    Console.WriteLine("Hi there."); 
    } 
} 

編譯器會只引用強制性mscorlib.dll中。

0

代碼中使用的名稱空間的數量對dot.net中的web或windows應用程序的運行時性能沒有任何影響,但它對編譯時間有一定的影響,因爲編譯器必須搜索那些未使用的名稱空間。