How to: Extract a Method Using Refactoring

Refactoring is a Code Editor feature that can make intelligent changes to your source code. For example, the refactoring option Extract Method will examine a block of C# and convert it into a method, replacing the existing code with a call to the new method.

To extract a method using refactoring

  1. Highlight a block of source code in your application.

  2. On the Refactor menu, click Extract Method.

  3. Type a name for your new method.

  4. Click OK.

  5. Confirm that the new method has the correct modifiers. By default the new method is given private accessibility.

See Also

Other Resources

Visual C# Express

Using the Visual C# Express IDE

Visual C# Express Tips and Tricks