如何使用名称空间删除未使用的 [英] 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
这篇关于如何使用名称空间删除未使用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!