Search code examples
asp.net.netperformancedllimportusing-statement

Is using the completed type name in code is faster than a using directive for the whole namespace


For the best website performance is using: (for example)

Telerik.Web.UI.RadChart ResultChart = new Telerik.Web.UI.RadChart();

Is faster than :

using Telerik.Web.UI;

and

RadChart ResultChart = new RadChart();

and what if i used the using directive in many modules in ASP.net page, does the compiler use it once?


Solution

  • It makes no difference. The compiled IL will contain the fully qualified name every time the type needs to be used.

    The using statement just makes your code file shorter and easier to read.

    The number of times a directive appears in your code also makes no difference - just the fact that the assembly that it is in is referenced by the project is enough.