ReSharper 8.0 Web Help

The Introduce Parameter refactoring allows you to add a new parameter into a method or constructor from an expression within its body. All calls to the method/constructor are automatically updated with the appropriate value passed as the new parameter.

If an expression that you want to pass as a parameter references symbols declared in the method body, ReSharper allows to "en-lambda" these symbols by introducing a delegate parameter and using it to pass a lambda expression from the caller (see procedure below for an example).

To introduce a parameter to a method or constructor
  1. In the editor, select an expression within a method or constructor.
  2. Do one of the following:
    • On the main menu, choose ReSharper| Refactor | Introduce Parameter.
    • Choose Refactor | Introduce Parameter on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Introduce Parameter.
    • Press Ctrl+Alt+PCtrl+R,P.
  3. If the selected expression occurs two or more times in the current method or constructor, ReSharper asks to specify how many occurrences should be replaced. If the selected expression occurs only once, the Introduce Parameter dialog box opens immediately.


  4. Enter the name for a new parameter in the Parameter name text box.
  5. If the selected expression requires passing the parameter as a lambda expression, select members to en-lambda in the Select local variables to en-lambda section.
  6. Click Next. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, resolve conflicts.

Consider the example below:


After applying the refactoring, the expression is replaced with the getAttribute parameter.


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available


The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.

See Also