ReSharper 8.0 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+RCtrl+Shift+R, then click Make Method Static.
  3. The Make Static dialog box opens.

    Refactorings__Make_Method_Static__dialog_box

  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:

Refactorings__Make_Method_Static__before

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

Refactorings__Make_Method_Static__after


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

Tip

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

Procedures: