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?

wonea
  • 4,783
  • 17
  • 86
  • 139
Jason Irwin
  • 1,985
  • 2
  • 29
  • 42

2 Answers2

3

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 ?

Community
  • 1
  • 1
Ahmad Mageed
  • 94,561
  • 19
  • 163
  • 174
2

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
  • 1,421,763
  • 867
  • 9,128
  • 9,194