overhead to unused “using” declarations?

From The C# Team’s answers to frequently asked questions:

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
… Don’t [waste] your time stripping out
unused ‘using‘ statements or assembly
references from your application. The
C# compiler will do so for you
automatically.

You can verify that this is actually the case by calling Assembly.GetReferencedAssemblies(); you’ll see that anything that isn’t used won’t actually be included in the list.

The main utility in stripping out unused ones is

  • It is easier to see what your code is actually using
  • It will keep your Intellisense from being polluted with things that you aren’t actually going to use.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)