yogi yogi - 1 year ago 87
C# Question

Performance impact of unused "using" directives in C#

Just curious about it.

Does it matter if I add multiple

directives at the starting of my code file which I don'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 have a bad impact on my application's memory usage?

  • Does it have a bad impact on my application's performance?

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.

Answer Source

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.