ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Make Method/Property Static refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Make Method Static…

To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_MakeStatic command.

This refactoring allows you to convert an instance method or a property to a static one. All calls, implementations and overrides are automatically corrected.

If the converted instance method uses instance members, ReSharper helps you add the necessary parameter representing this to apply these usages to. If the converted instance property uses instance members, the refactoring is not available.

In the example below, we use this refactoring to convert an instance method Merge of the Info class into a static method. After refactoring, usages of instance properties Id and Name are applied to the new parameter i1:

ReSharper. 'Make Static' refactoring

This feature is supported in the following languages and technologies:

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