To introduce a parameter to a method or constructor
  1. In the code editor, select an expression inside a method or constructor:
    Refactorings__Introduce_Parameter__before.png
    Image 1:
  2. Choose ReSharper | Refactor | Introduce Parameter, or press Ctrl+Alt+P.
    • If the selected expression occurs two or more times in the current method or constructor, ReSharper asks to specify how many occurrences it should replace:
      Refactorings__Introduce_Parameter__replace_occurrences.png
      Image 2:
    • If the selected expression occurs only once, the Introduce Parameter wizard opens immediately:
      Refactorings__Introduce_Parameter__dialog_box.png
      Image 3:
  3. Specify the following options:
    • In the Parameter name text box, choose a suggested name for the new parameter, or enter a custom name.
    • 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.
  4. Click Next. If ReSharper discovers no conflicts, the refactoring is applied immediately. The following figure shows how ReSharper generates a delegate parameter:
    Refactorings__Introduce_Parameter__after.png
    Image 4:
    This is how a method call transforms to pass a lambda expression:
    Refactorings__Introduce_Parameter__call.png
    Image 5: