Remove Parameters

Remove Parameters is a refactoring operation that provides an easy way to remove parameters from methods, indexers, or delegates. Remove Parameters changes the declaration; at any locations where the member is called, the parameter is removed to reflect the new declaration.

You perform the Remove Parameters operation by first positioning the cursor on a method, indexer, or delegate. While the cursor is in position, to invoke the Remove Parameters operation, click the Refactor menu, press the keyboard shortcut, or select the command from the shortcut menu.

When you invoke the Remove Parameters command, the Remove Parameters dialog box appears. For more information, see Remove Parameters Dialog Box or How to: Remove Parameters.

Note

You cannot remove the first parameter in an extension method.

Remarks

You can remove parameters from a method declaration or a method call. Position the cursor in the method declaration or delegate name and invoke Remove Parameters.

Warning

Remove Parameters enables you to remove a parameter that is referenced in the body of the member, but it does not remove the references to that parameter in the method body. This can introduce build errors into your code. However, you can use the Preview Changes Dialog Box to review your code, before executing the refactoring operation.

If a parameter being removed is modified during the call to a method, the removal of the parameter will also remove the modification. For example, if a method call is changed from:

    MyMethod(param1++, param2);

to

    MyMethod(param2);

by the refactoring operation, param1 will not be incremented.

See Also

Tasks

How to: Remove Parameters

Concepts

Refactoring