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
Highlight a block of source code in your application.
On the Refactor menu, click Extract Method.
Type a name for your new method.
Click OK.
Confirm that the new method has the correct modifiers. By default the new method is given private accessibility.