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
Place the caret in a variable declaration.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Make Explicit from the menu (Make Implicit if the variable is declared explicitly).
After execution, the Refactoring changes the variable type to implicit or changes the implicit type to the explicit type.
The Make Implicit/Explicit refactoring also supports out variables.
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.