ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Extract Method refactoring

Last modified: 23 May 2023

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 more information about other languages, refer to corresponding topics in the ReSharper by language section.