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

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

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

    double a = 1.42;
    
  2. Use 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.

double a;
a = 1.42;
See Also