Split Initialization from Declaration
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
Place the caret on a variable name in its initialized 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 Split Initialization from Declaration from the menu.
After execution, the Refactoring moves the variable initialization to the separate statement.
See Also