Make Implicit/Explicit

Purpose

Converts an explicitly-typed variable declaration to an implicitly-typed variable and vice versa. You can use implicitly typed variables to avoid redundant code and increase code readability. The explicit typing helps to avoid mistakes.

Availability

Available when the caret is in a variable declaration.

Usage

  1. Place the caret in a variable declaration.

    NOTE

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

    var i = 10;
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Make Explicit from the menu (Make Implicit if the variable is declared explicitly).

    Choose Make Explicit Menu Item

After execution, the Refactoring changes the variable type to implicit or changes the implicit type to the explicit type.

int i = 10;

The Make Implicit/Explicit refactoring also supports out variables.

Make Implicit Out Variable

NOTE

You can use the "Apply variable declaration style" code cleanup rule to change the variable type to explicit.

Blazor Support

You can apply the Make Explicit refactoring from code sections in a .razor file.

Make EXplicit bLAZOR

See Also