ReSharper Web Help

When you reference a type that has not been imported yet, ReSharper helps you locate this type and add it to the list of namespace import directives. The new directive is added to the list, but the caret stays in the current position, and your editing session is not interrupted.

It is important to note that "using" directives are added in alphabetical order: all System.* namespaces go first, sorted alphabetically by the second word after dot; all the rest namespaces go next, in alphabetical order.

Depending on your code inspection settings , the prompt to add a directive appears as a pop-up window or as a quick-fix. You can also opt to resolve references to non-imported types with either using directives or fully qualified names (see C# Language Options: Namespace Imports and VB.NET Language Options: Namespace Imports for the list of available options).

To add a namespace import directive on-the-fly
  1. Start typing a name in the editor. If the name references a class that lacks a namespace import directive, the following pop-up window displays:
  2. Press Alt+Enter. If there's a single choice, the namespace will be imported right away. If there are multiple choices, a drop-down list will display where you can select a required type:

For guidelines on how to import a type with a quick-fix, see Examples of Quick-Fixes: Missing Using Directives .

When you paste a large block of code, a lot of types may not resolve because of missing namespace import directives in the current file. To simplify the task of adding all required directives, ReSharper provides a prompt.

To add namespace import directives for all types
  1. Paste a block of code into the desired file.
  2. If the block of code contains types that lack namespace import directives, the following pop-up prompt displays.
  3. Press Alt+Enter or click to insert all required namespace import directives.

See Also