This website completely moved to new platform. For latest content, visit www.programmingposts.com

Search this Site

24 Apr 2013

How To Remove Unused Usings / Namespace in Visual Studio

There are two ways to remove unused using from our code . Remove Unused Usings option in Visual Studio removes unused using (namespace) in our code .

The first way is :

1) Main Menu - On the Edit menu, point to IntelliSense, point to Organize Usings, and then click Remove Unused Usings.

(click on image for clear view)

Unused_Usings_1

2) Context Menu - Right-click anywhere inside the code editor, point to Organize Usings, and then click Remove Unused Usings.

Unused_Usings_2

The following example shows the outcome of performing Remove Unused Usings on source code.

Before:



using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}

After:

using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World");
}
}