|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Add using is a Visual C# IntelliSense feature that provides an easy way to search for the namespace that declares an unbound type that is present in your code, and then add a using directive for that namespace to your code or fully qualify the instance of the unbound type.
An unbound type is a type referenced in the project that IntelliSense and the C# compiler cannot match to a declaration. Referencing the namespace that declares the type, as with a using directive, enables IntelliSense and the compiler to read the type.
If an unbound type is nested in multiple namespaces or types, IntelliSense displays more than one suggestion about what to bind the unbound type to. The maximum number of suggestions that IntelliSense can display at a time is five using statements and five fully qualified names.
The Add using IntelliSense operation enables you to maintain your focus on the code you are writing rather than requiring you to shift your focus to another part of the code.
To initiate the Add using operation, position the cursor on a type reference that cannot be resolved. For example, when you create a Console Application and then add XmlTextReader to the body of the Main method, a smart tag will appear under the rightmost character of XmlTextReader, since it appears as a type reference that cannot be resolved.
You can then invoke the Add using by selecting it from Resolve submenu of the IntelliSense menu or the context menu, or by invoking Add using through the smart tag. The smart tag is only visible when the cursor is positioned on, or adjacent to, the unbound type.
When you invoke the Add using operation, the using directive is added to the beginning of the source code. For more information, see.