c# - .net 中未使用的用途是否会影响性能?

标签 c# .net namespaces

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 的插件,它可以帮助您删除整个项目中所有未使用的内容。

http://www.addictivetips.com/windows-tips/batch-format-remove-unused-usings-and-format-visual-studio-document/

关于c# - .net 中未使用的用途是否会影响性能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12026820/

相关文章:

c# - Knockoutjs 绑定(bind)对象问题

c# - .NET 是否有任何可用的方法来获取两个字符串的差异?

c# - Controller Action 中的长时间运行方法 - MVC

.net - wcf tcp async streamed 是可能的吗?

php - Laravel 5 单元测试和命名空间

php - 如何用PHP获取SVG标签内容

c# - 在查询中将 DateTime.Ticks 转换为 MySQL DateTime

c# - 编写检查内存泄漏的测试。什么是可行的方法?

c# - 在 Visual Studio 中使用 Windows 身份验证服务进行客户端开发

c++ - 范围解析运算符被使用两次