Search code examples
.netlanguage-features

Do Redundant Namespaces incur any overhead


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?


Solution

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