Back to Devexpress

Make Implicit/Explicit

coderushforroslyn-115552-refactoring-assistance-make-implicit-explicit.md

latest1.8 KB
Original Source

Make Implicit/Explicit

  • Nov 03, 2023

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.

  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).

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

csharp
int i = 10;
vb
Dim i As Integer = 10

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.

See Also

Make Read-Only

Convert to System Type/Built-In Type