The requested page is not available for the requested platform. You are viewing the content for Default platform.

Move Initialization to Declaration

Combines the declaration of a local variable with its initialization or first assignment.

Purpose

  • Having the initialization on the same line as the declaration usually makes the code a bit easier to read.
  • Move Initialization to Declaration is also useful if you had conditional local initialization which has been eliminated.

Availability

Available from the context menu or via shortcuts:

  • when the edit cursor, or caret is on a local variable that is declared without an initialization.

Tips

Example

int a;
a = 15;
Dim a As Integer
a = 15

Result:

int a = 15;
Dim a As Integer = 15

Animation

CSharpMoveInitializationToDeclaration

See Also