Possible Duplicate:
Why should you remove unnecessary C# using directives?
How is performance affected by an unused using statement
C# 中未使用的 using 会影响运行时性能吗?如果是,怎么做?
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;
最佳答案
不会,但它会影响 IDE 性能和项目的编译过程。 我可以给你举一个简短的例子。如果您曾经使用过coderush http://devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/来自 devexpress,他们的 IDE 优化器和代码优化器也会建议您删除未使用的命名空间。
更新:以下是来自 Dmitriy 博客的更多使用信息 您应该删除 C# 代码中未使用的 using 有几个原因。
•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
有几种方法可以删除那些未使用的用法,您可以在每个文件上单独执行此操作
http://msdn.microsoft.com/en-us/library/bb514115.aspx
您还可以下载 Visual Studio 2010 的名为batchFormat 的插件,它可以帮助您删除整个项目中所有未使用的内容。
关于c# - .net 中未使用的用途是否会影响性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12026820/