Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

Whenever you create a new code file in Visual Studio, it adds a default set of using namespaces automatically to faster the development process in common name resolution. Not all of them are mandatory to use and can be remove at later point of time or before code check-in.

 

Visual Studio 2015 provides us an easy way to organize the using namespaces within the active code file, project and/or solution. You will really love this new feature. Continue reading to learn more about it.

 

Visual Studio 2015 Tips & Tricks - How to organize "using namespaces" easily across project/solution? (www.kunal-chowdhury.com)

 

The old versions of Visual Studio already has the way to organize the using statements, but that is only applicable within the active code file. If you want to cleanup unnecessary namespace declaration, you had to manually open each files, right click on them and from the context menu you had to visit “Organize Usings” and then had to select the appropriate menu items in order to sort and remove unnecessary declarations.

 

Here you can find the screenshot of the same to visualize it:

 

Visual Studio Tips & Tricks - Old ways to organize using namespaces

 

 

Visual Studio 2015 also provides the same functionality. You can follow the same steps in order to remove the unused using namespaces from individual file. But as you know, the process is very lengthy when you want to do this for all the files available in a project or a solution.

 

The new feature allows you to easily remove the unnecessary using namespaces from individual file or files within a project/solution. You can also preview all the changes before actually committing it. To do this, open any code file and click the small bulb near to the using declarations as shown below:

 

Visual Studio 2015 Tips & Tricks - New way to remove unnecessary using namespaces

 

Inside the popup menu, you can find a panel with three different links named Document, Project and Solution. If you want to perform this operation within the same document, click “Document”; for project or solution click the respective link. Once clicked, Visual Studio 2015 will automatically start removing all unnecessary using namespaces from your code.

 

I hope, it was clear from the above post. Please let me know if you have any comments. Also, don’t forget to read my other posts on Visual Studio 2015 Tips & Tricks available in this web URL:  http://visual-studio-2015.kunal-chowdhury.com

 

Have a question? Or, a comment? Let's Discuss it below...

dhgate

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.