The Make Method/Property Static refactoring allows you to convert an instance method or property to a static method or property. All calls, implementations and overrides of the method/property are automatically corrected.
In 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
- Position the caret at the name of a method or property in the editor:
- Choose ReSharper | Refactor | Make Method Static or ReSharper | Refactor | Make Property Static. The Make Method Static wizard will display:
- Specify the following options:
- If any class members are referenced in the body of the method, you can add parameter(s) to the new static method signature.
You can do either or both of the following:
- Add 'this' as parameter with name: the current class will be added. Select a name for the parameter from the list of suggestions or specify a custom name.
- Add parameters for fields: in the list below, select the necessary fields to add them as parameters. Optionally, type in new parameter names in the Parameter Name box for each field.
- Click Move Up or Move Down to change the order of the new parameters.
- If any class members are referenced in the body of the method, you can add parameter(s) to the new static method signature. You can do either or both of the following:
- Click Continue. If no conflicts are found, the refactoring is performed immediately: