views:

81

answers:

2

Other than maintenance complexity (and I would argue there is little to none), and the fact that it is not a clean solution (this I agree with) does importing redundant namespaces in a .NET class incur any overhead in terms of memory/space/etc.?

For instance, if i import My.Namespace but do not invoke any of its functionality, is the Visual Studio compiler smart enough not to package the corresponding binaries when my application is being deployed?

+1  A: 

There's no overhead for this, no. Note that the "My" namespace doesn't require you to deploy any extra binaries anyway - everything's in the Visual Basic assemblies shipped with the framework.

Jon Skeet
+2  A: 

From the C# FAQ:

When you add assembly references or make use of the 'using' keyword, csc.exe will ignore any assembly which you have not actually made use of in your code.

There are 2 related questions about this:

  1. Why should you remove unnecessary C# using directives?

  2. overhead to unused “using” declarations ?

Ahmad Mageed