BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Refactoring
VS 2005+

Visual Studio Reorder Parameters Command

When creating class libraries, you may decide to refactor your code to provide a consistent ordering of parameters. If you need to change the order of parameters for existing methods, you can use Visual Studio's Reorder Parameters command.

Reorder Parameters Command

Sometimes, when reading existing code, you will find methods with parameters that are ordered illogically, or where parameters appear in a different order to other, similar methods. If you would prefer that the parameters appeared in a consistent and logical order, you must update the method's signature and the code for every call to that method. If you attempted this for widely used methods, it would be a time-consuming process and one that was prone to error.

Visual Studio's Reorder Parameters command simplifies the process. Instead of manually updating the code, the command provides a dialog box that permits you to interactively change the order of the parameters for a method. Once accepted, Visual Studio automatically modifies the method and all of the references to it that appear within the current solution.

To use the command, right-click the method that you wish to adjust. Choose"Refactor" from the context-sensitive menu that is displayed and then select the Reorder Parameters option.

Visual Studio Reorder Parameters Menu Option

After the command is selected, the Reorder Parameters dialog box will be displayed. The dialog box lists the method's parameters. To change the order of the parameters, click the item that you wish to move in the list. Next, click the up or down arrow buttons to move the selected item. A preview of the changes is displayed as you make them. Once you are satisfied with the new signature, click the OK button to perform the updates.

22 February 2009