Remove Unused Using Statements

by Shabbir on May 12, 2008

in C#

When we create a new C#.Net project (or other .Net project, , the editor includes the following using statements in the code

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

But most of this included namespaces are unused, and you don't know which of them you don't need.
So, in Visual Studio 2008 there is a new feature for excluding the unused usings from your project.
In the code editor, click the right mouse button and in the context menu go to Organize Usings -> Remove and Sort

Remove unused usings

If you have not written additional code, the editor will leave this two using statements

  1. using System;
  2. using System.Windows.Forms;

Sharing is Caring...

{ 2 comments… read them below or add one }

Tushar March 30, 2010 at 4:56 pm

I have a question here. As part of code clean-up and making code more readable, this makes perfect sense. Let's say you decide to retain all the unused usings and not remove them. Will that be a Performance impact on the app?

Reply

Shabbir Bhimani March 31, 2010 at 2:09 am

Modern day compiler is smart enough to not overload the executable but its always better to control the controllable.

Reply

Leave a Comment

Previous post:

Next post:

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.