Skip to main content

Compress/Expand Assignment

Purpose

Converts an assignment to its short form or expands the short form assignment to a full assignment expression. Short form assignments are more compact and clearer than the full expressions.

Availability

Available when the caret is at the beginning of a compressible assignment expression or a short form assignment.

Usage

  1. Place the caret at the beginning of a compressible or expandable assignment expression.

    Note

    The blinking cursor shows the caret’s position at which the Refactoring is available.

    a = a + b;
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Compress Assignment from the menu (Expand Assignment if you are expanding the short form assignment).

After execution, the Refactoring converts the assignment to its short form or vice versa.

a += b;
See Also