【问题标题】:c# overplus name space increase load on page?c# overplus名称空间增加页面负载?
【发布时间】:2013-07-15 12:07:48
【问题描述】:

在 c# asp.net web 表单或 win 表单应用程序上使用未使用的命名空间会增加应用程序负载吗?我在实施完成时删除了未使用的

【问题讨论】:

    标签: c# asp.net namespaces


    【解决方案1】:

    简短的回答是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。

    【讨论】:

      【解决方案2】:

      代码中使用的命名空间数量对 dot.net 中的 Web 或 Windows 应用程序的运行时性能没有任何影响,但它对编译时间有一些影响,因为编译器必须搜索那些未使用的命名空间。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-05-17
        • 1970-01-01
        • 2016-04-04
        • 1970-01-01
        • 2012-07-06
        • 1970-01-01
        • 1970-01-01
        • 2015-10-01
        相关资源
        最近更新 更多