Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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.

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.

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).

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

The using directive is just syntactic sugar.

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top