JetBrains Rider
 
Get JetBrains Rider
Get your hands on the new features ahead of the release by joining the Early Access Program for Rider 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, JetBrains Rider 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:

JetBrains Rider: 'Introduce Parameter' refactoring