ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Introduce Parameter refactoring

Last modified: 23 September 2024

This refactoring allows you to move an expression from a method implementation to its callers by adding a new parameter. All occurrences of the expression are replaced with the new parameter; all calls to the method in the solution are updated with the new argument.

In the example below, we use this refactoring to replace two occurrences of the same string with a parameter. The string itself is moved to the caller argument:

If the expression that you want to pass as a parameter references variables declared in the method body, ReSharper allows you to 'enlambda' these variables by introducing a generic delegate parameter and using it to pass a lambda expression from the caller. In the example below, we invoke the refactoring for the "The current time is: " + currentTme expression:

ReSharper: 'Introduce Parameter' refactoring

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.