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

Make Method Non-Static refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Make Method Non-Static…

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

This refactoring allows you to convert a static method into an instance method of the original or another type. The target type for the new instance method can be selected from one of the types passed as parameters to the method. All usages, implementations and overrides of the method are automatically updated.

This refactoring can only be applied to static methods that have at least one parameter of a type defined in the current solution.

In the example below, we use this refactoring to convert a static method Merge of the Info class into an instance method of the same type:

In the following example, the static method Merge that works with Info objects is defined in the class Service. We use the refactoring to make Merge an instance method of the class Info, where it logically belongs:

ReSharper: Make method non-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.