For example:
using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.Web.Script.Serialization; using System.Web.Script.Services; using System.Web.Security; using System.Data; using System.IO; using System.Net; using System.Text; using System.Xml; using System.Xml.XPath; using System.Web.Configuration; using System.Collections.Generic;
I have something like that in a class that I have inherited. I could remove each namespace one by one to see if the class builds, BUT does it matter?
If I am not sure if System.Xml is needed, should I remove it?
In general all they do is add clutter.
However, they can in some specific circumstances cause problems with duplicate names in scope, or duplicate extension methods. For example, if there are classes
Foo.SomeTypeandBar.SomeType, and you haveusing Foo;andusing Bar;, then references toSomeTypewill need disambiguating. The extension methods work similarly where static classes in different namespaces contribute conflicting extension methods.The VS2008 tools (including express) include options to remove unnecessary
usingstatements, which is very useful for tidying the code.