.net 中未使用的用法会影响性能吗? [英] Do unused usings in .net affect performance?

查看:21
本文介绍了.net 中未使用的用法会影响性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
为什么要删除不必要的 C# using 指令?
未使用的 using 语句对性能有何影响

c# 中未使用的用法会影响运行时性能吗?如果是,怎么做?

Do unused usings in c# affect runtime performance? If yes, How do so?

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 优化器和代码优化器也会建议您删除未使用的命名空间.

NO, but It effects the IDE performance and the compilation process of your project. I can give you a short example. If you have ever used coderush http://devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/ which is from devexpress, their IDE optimizer and code optimizer will also suggest you to remove unused namespaces.

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

Update: Here is more use information from Dmitriy's Blog There are few reasons why you should remove unused usings in you C# code.

•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

有几种方法可以删除那些未使用的内容,您可以在每个文件上单独删除

There are couple ways to remove those unused usings, you can do it individually on each file

http://msdn.microsoft.com/en-us/library/bb514115.aspx

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

You also can download plugin called batchFormat for Visual Studio 2010 that can help you to remove all unused usings for the whole project.

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

这篇关于.net 中未使用的用法会影响性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆