Back to Devexpress

Split Initialization from Declaration

coderushforroslyn-116584-refactoring-assistance-split-initialization-from-declaration.md

latest1.2 KB
Original Source

Split Initialization from Declaration

  • Aug 03, 2020

Purpose

This Refactoring is used when the variable is declared and initialized in the same statement. It breaks this statement into two lines: separates the initialization from declaration. It is useful for conditional initialization, or when you need to widen the scope of the declaration.

Availability

Available when the caret is on a variable name in the statement where it is declared and initialized.

Usage

  1. Place the caret on a variable name in its initialized declaration.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Split Initialization from Declaration from the menu.

After execution, the Refactoring moves the variable initialization to the separate statement.

csharp
double a;
a = 1.42;
vb
Dim a As Double
a = 1.42

See Also

Move Initialization to Declaration

Move Declaration Near Reference