#758 – Cleaning Up using Directives in a File

2,000 Things You Should Know About C#

You use using directives at the top of a file to bring various namespaces into scope, so that you don’t need to fully qualify named members within those namespaces.

Extra using directives don’t hurt anything–the list of directives is just a list of possible namespaces to consult when resolving a name.  Your code may not actually reference members in all of the listed namespaces.

For cosmetic purposes, however, there is an easy command in Visual Studio that you can use to clean up using directives for namespaces that you don’t use.

To remove unused namespaces, you can right-click in the source code editor and select Organize Usings and then Remove Unused Usings.  After you do this, you’ll be left only with namespaces that contain members that your code contains.

758-001

 

758-002

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s