11

重複の可能性:
ディレクティブを使用して不要なC#を削除する必要があるのはなぜですか?
未使用のusingステートメントによってパフォーマンスはどのように影響を受けますか

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; 
4

2 に答える 2

13

いいえ。ただし、IDEのパフォーマンスとプロジェクトのコンパイルプロセスに影響します。簡単な例を挙げましょう。devexpressからのcoderushhttp : //devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/を使用したことがある場合は、IDEオプティマイザーとコードオプティマイザーも未使用の名前空間を削除するように提案します。

更新: Dmitriyのブログからのより多くの使用情報がありますC#コードで未使用の使用を削除する必要がある理由はいくつかあります。

•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/

于 2012-08-19T13:30:13.970 に答える
0

いいえそうではありません。実際、使用されているかどうかに関係なく、実行時の重要性はまったくありません。これらは、コンパイラがフルネームを明示的に指定せずに型を認識できるようにするための単なるコンパイル時定数です。

彼らの主な問題は、未使用usingのsでいっぱいのファイルが、コードを調べるときに無意味なPgDnを作成することを余儀なくされることです。

于 2012-08-19T13:29:17.053 に答える