如何删除未使用的 using 命名空间 [英] How to remove unused using namespaces
问题描述
我正在使用 Visual Studio 2010,想知道是否有办法自动删除页面顶部未使用的所有命名空间,例如
I am using visual studio 2010 and was wondering if there is a way to automatically remove all the namespaces that aren't being used at the the top of the page e.g.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
在上面的例子中,System.Collections.Generic 没有被使用,有没有办法不用反复试验就知道这一点.
in the above example System.Collections.Generic is not being used is there a way to know that without trial and error.
推荐答案
是的,您可以右键单击页面并从菜单中选择;
Yes you can right click on the page and from the menu select;
Organise Usings > Remove Unused Usings
或者,如果您更喜欢快捷方式,请使用;
Alternatively if you prefer shortcuts, please use;
Ctrl + R + G
我一直在使用它来清理代码,并使代码编译更快.
I am using this all the time, to clean up code, and make code compilation quicker.
或者您可以使用 PowerCommands 删除未使用的整个项目
Or you can use PowerCommands to remove unused usings for entire projects
这篇关于如何删除未使用的 using 命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!