Back to Devexpress

Remove Redundant Assignment

coderushforroslyn-115558-refactoring-assistance-remove-redundant-assignment.md

latest1.2 KB
Original Source

Remove Redundant Assignment

  • Aug 03, 2020

Purpose

Removes the initialization of a variable if it is initialized with the default value.

Availability

Available when the caret is on the name of a field in its declaration, provided that the field is initialized with the default value.

Usage

  1. Place the caret on the name of a field in its declaration.

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

  3. Select Remove Redundant Assignment from the menu.

After execution, the Refactoring removes the assignment, which does not change code behavior.

csharp
private int sum;
vb
Private sum As Integer

See Also

Remove Unused Member

Add/Remove Block Delimiters

Remove Redundant Constructor

Remove Type Qualifier