KnowDotNet NetRefactor

NET Refactor - Rename Local Variables

One of the most important parts of keeping your code readable and maintainable is to use proper naming of variables and methods. The Rename Local Variables feature of NET Refactor allows you to change the name of any or all of the variables in a method, and at the same time have all of the references to the renamed variables changed automatically. To use Rename Local Variables, simply place the cursor, anywhere in the method in which you wish to rename the variables, and select the menu option from the NET Refactor menu. Upon selection of the Rename Local Variables menu option, the dialog shown below will be displayed.

Rename Local Variables Dialog


Renaming Variables


The variable selected in the ListView will always be displayed in the TextBox at the bottom of the dialog. Having selected a variable in the ListView, press Tab to enter the TextBox. The variable will be highlighted so that you can begin typing the new name. You will see the new name entering the ListView as you type.

In the dialoag, shown above, you will see that there appears to be duplicate variables. If you look at the selection behind the dialog, you will see that you can duplicate variable names within code blocks such as For...Next loops, etc. The Rename Local Variables handles this situation by remembering the Scope of each of the variables and handling the changing of names and references according to their respective scope.

Once you have renamed all of the variables that you wish to rename, click OK and the code block will be replaced with the new block containing the renamed variables and references.

Try NET Refactor Free for 20 days or purchase now by clicking Download or Purchase.

Top of Page



Writing Add-Ins for Visual Studio .NET
Writing Add-ins for Visual Studio .NET
by Les Smith
Apress Publishing