Back to Devexpress

Move Declaration Near Reference

coderushforroslyn-116585-refactoring-assistance-move-declaration-near-reference.md

latest953 B
Original Source

Move Declaration Near Reference

  • Aug 03, 2020

Purpose

Moves a local variable declaration to the closest point before its first usage. This increases the code readability.

Availability

Available when the caret is on a local variable name in its declaration.

Usage

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

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

  3. Select Move Declaration Near Reference from the menu.

After execution, the Refactoring moves the variable declaration to the closest point before its first usage.

csharp
// ...
double a;
a = 42;
// ...
SendNumber(a);
vb
' ...
Dim a As Double
a = 42
' ...
SendNumber(a)

See Also

Move Initialization to Declaration