Why does Visual Studio 2008 automatically insert the following using directives into each new C# file I create?
using System;
using System.Collections.Generic;
using System.Text;
What's so special about these namespaces? Are these the most frequently used ones?
The using directive can appear: At the beginning of a source code file, before any namespace or type declarations. In any namespace, but before any namespaces or types declared in that namespace, unless the global modifier is used, in which case the directive must appear before all namespace and type declarations.
:: operator (C# reference) The global namespace is the namespace that contains namespaces and types that are not declared inside a named namespace. When used with the :: qualifier, the global alias always references the global namespace, even if there is the user-defined global namespace alias.
The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types. C# Copy.
Run regedit . If you want to install the directive processor in the experimental version of Visual Studio, insert "Exp" after "11.0". Add a registry key that has the same name as the directive processor class. In the registry tree, right-click the DirectiveProcessors node, point to New, and then click Key.
Yes, they're frequently used, that's all, so MS put them in the Visual Studio templates. Personally I use "sort and remove unused usings" pretty frequently, so they often go away.
If you want to remove them, you can amend the "new class" template.
EDIT: If you become a fan of "Sort and Remove Unused Using Directives" you should get hold of PowerCommands for Visual Studio - that adds a Solution Explorer context menu item to do it for a whole project instead of just one file :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With