Is it worth removing "using System" from my files?

998 views Asked by At

Developing a series of POCOs on my project, and just realized that some of them doesn't need the using System; clause.

Is there any performance or size penalty for leaving unused using <module>; on my objects or project ?

Will my classes get bigger, or slower, or bloated because of this or the compiler/optimizer is smart enough to take care of this?

8

There are 8 answers

1
Massimiliano Peluso On BEST ANSWER

no there are not performance issue .

it is just a readability matter(I would suggest to remove them)

more info at: Why should you remove unnecessary C# using directives?

0
abatishchev On

That brings neither performance gain nor hit.

I remove all unused and sort all used usings as code style (neatness). You can do this via Visual Studio context menu (I bound it to a hotkey).

0
itsme86 On

All the "using System;" statement does is allow you to use that namespace without fully qualified names. It doesn't affect run-time performance in any way.

0
JaredPar On

There is no runtime performance penalty for having unused using statements in your code. They don't appear is the compiled DLL in any form (they do exist in the PDB).

However if you know them to be invalid it's generally considered good style to remove them. Having unused usings is essentially stating a false dependency your code has on a set of types and extension methods.

Determining which usings are not used is a tedious process. I find it's best to just install a tool like PowerCommands and let it do the work on file save.

0
MethodMan On

If you are not using a reference / assembly or extended functionality for example using System.Linq; by default gets added to VS2010 projects.. if you don't use it.. just remove it.. no performance issues

0
McKay On

The using directive is just syntactic sugar.

Adding using references will not affect performance other than a marginal compile-time difference.

0
Saurabh On

It in no way affects the output of the compiler or the performance of the compiled program!

It can be removed a as part of personal preference. I would personally recommend it as it would make the compilation faster (fewer namespaces for the compiler to look up) and also improve the performance of intellisense.

0
Lily Finley On

It has no impact on performance. It can be kept or removed at your discretion.

However, consider keeping it. The System namespace contains the most commonly used parts of the .NET Framework, and at some point during the lifetime of your file, you (or someone) will probably end up needing it. That means inevitably putting it back, possibly after wasting time wondering why none of the system classes exist.