ReSharper for Visual Studio Code Help

Extract Method refactoring

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

Consider the following example. The method PrintReversed() actually does two things: it reverses the string and prints it. We can select the reversing logic, which is all statements except Console.WriteLine(reversed);, and use this refactoring to move that logic to a new method.

static void PrintReversed(string input) { var chars = input.ToCharArray(); Array.Reverse(chars); var reversed = new string(chars); Console.WriteLine(reversed); }
static void PrintReversed(string input) { var reversed = ReverseStr(input); Console.WriteLine(reversed); } private static string ReverseStr(string input) { var chars = input.ToCharArray(); Array.Reverse(chars); var reversed = new string(chars); return reversed; }

Extract a method from selected statements

  1. In the editor, select one or more statements that you want to convert into a method.

  2. Right-click and choose Refactor | Extract Method from the context menu.

  3. In the popup that opens, select Extract Method.

ReSharper: Extract Method refactoring

Extract local function from selected statements

  1. In the editor, select one or more statements that you want to convert into a local function.

  2. Right-click and choose Refactor | Extract Method from the context menu.

  3. In the popup that opens, select Extract Local Function.

17 February 2026