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

Extract Method refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Extract | Extract Method…

Ctrl+R M (ReSharper_ExtractMethod)

This refactoring allows you to create a new method or a local function based on the selected code fragment. ReSharper analyses the selected statements and detects variables that can be converted into method parameters or represent its return value.

Consider the following example:

ReSharper. Extract Method 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.