ReSharper Web Help

The Make Method/Property Static refactoring allows you to convert an instance method or a property to a static one. All calls, implementations and overrides of the method/property are automatically corrected.

When you are making a method static, you can choose to add parameters to it from the list of class members referenced in its body. Reverse functionality is available with the Make Method/Property Non-Static refactoring.

To make a method or property static
  1. Place the caret at the name of a method or property in the editor.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Make Method Static.
    • Right-click, then click Refactor | Make Method Static on the context menu.
    • Press Ctrl+Shift+R, then click Make Method Static.
  3. The Make Static dialog box opens.

  4. Click one of the following:
    • Do not add parameters to the method
    • Add 'this' as parameter of [type name] to add a parameter with the enclosing type and type a new name in the Parameter name text box or leave the default one.
    • Introduce parameters from following expressions to add a separate parameter for each expression. In the list below, select the necessary expressions to add them as parameters.
  5. Click Next. If no conflicts are found, the refactoring is performed immediately. Otherwise, resolve conflicts.

Consider the example below:

After applying the refactoring, the method is made static, mySubmitter and mySettings fields are now passed as parameters to the method.

See Also

Procedures