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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
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

using System;
using System.Windows.Forms;

Sharing is Caring...

Other Related Posts:

  1. Using the Timer Class
  2. Creating a Windows Forms Application in C#
  3. Write To File in C#
  4. Read/Write Registry Keys
  5. Adding Items to ListView Control

{ 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

Spam protection by WP Captcha-Free

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.