Remove Type Qualifier

Purpose

Converts the full-form type reference into the short form. This Refactoring removes the redundant type qualifier from types referenced using its full form (e.g., System.Text.StringBuilder) and adds the corresponding namespace reference if it does not already exist. This makes your code more concise, although it can decrease readability in special cases.

Availability

Available when the cursor is on a type referenced using its full form.

Usage

  1. Place the caret on a full-form type reference.

    Note

    The blinking cursor shows the caret's position at which the Refactoring is available.

    namespace CRRDemo {
        class Program {
            static void Main(string[] args) {
                var o = new System.Text.StringBuilder();
            }
        }
    }
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Remove Type Qualifier menu item.

After execution, the Refactoring removes the namespace from its reference and ensures it is referenced.

using System.Text;

namespace CRRDemo {
    class Program {
        static void Main(string[] args) {
            var o = new StringBuilder();
        }
    }
}
Note

If you need to remove the type qualifier from all full-form type references in the current file, use the Remove Type Qualifier (remove all) Code Actions Menu item.

See Also