Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在.net中未使用会影响性能吗?_C#_.net_Namespaces - Fatal编程技术网

C# 在.net中未使用会影响性能吗?

C# 在.net中未使用会影响性能吗?,c#,.net,namespaces,C#,.net,Namespaces,可能重复: 在c#中未使用会影响运行时性能吗?若有,如何处理 using System; using System.Collections.Generic; using System.ComponentModel; -----//Unused using System.Data;---------------//Unused using System.Drawing;-----------//Unused using System.Text;-------------//Unused usi

可能重复:

在c#中未使用会影响运行时性能吗?若有,如何处理

using System;
using System.Collections.Generic;
using System.ComponentModel; -----//Unused
using System.Data;---------------//Unused
using System.Drawing;-----------//Unused
using System.Text;-------------//Unused
using System.Windows.Forms;
using System.Threading;------//Unused
using System.Linq;----------//Unused
using System.IO;-----------//Unused
using System.Diagnostics;-//Unused
using System.Data.OleDb;
using OBID; 

不,他们没有。事实上,无论它们是否被使用,它们都没有任何运行时意义。它们只是一个编译时常量,允许编译器在不显式指定类型全名的情况下识别类型


他们的主要问题是,使用s的文件中充满了未使用的
,这会迫使您在查看代码时生成一个毫无意义的PgDn。

否,但它会影响IDE性能和项目的编译过程。 我可以给你举个简单的例子。如果您曾经使用过来自devexpress的coderush,他们的IDE优化器和代码优化器也会建议您删除未使用的名称空间

更新:这里是来自Dmitry博客的更多使用信息 您应该删除C代码中未使用的using的原因很少

有两种方法可以删除这些未使用的using,您可以在每个文件上单独执行

您还可以下载名为batchFormat for Visual Studio 2010的插件,该插件可以帮助您删除整个项目中所有未使用的用法


@AvnerShahar Kashtan那么,你为什么不投票赞成结束投票呢?:-)当我注意到复制品时,我就把它标记了出来,但我认为我还不能投票决定是否关闭。
•It is useless code, that just creates clutter in your source code and it also confusing for the developer because you don’t know which namespaces are actually used.
•Over time as your code changes it can accumulate a lot of unused using statements which create even more clutter in you code.
•It can make your compiling faster, since compiler does not have to look up all those extra unused namespaces.
•It will help avoid name conflict with new items that you going to add to your solution if both of those have same names.
•It will reduce number of items in your Visual Studio editor auto completion