Refactoring – Extract Method

Refactoring is a disciplined technique of restructuring your existing body of code by altering its internal structure without changing its external behavior. If you have written code to perform a specific function in your application, you can refactor it into a method that you can reuse throughout your application whenever you need it.

Rather than manually creating a new method, the Extract Method refactoring in Visual Studio .NET automatically generates the new method and replaces the selected code with a method invocation. You simply select the code statement(s) that represent the logic of the new method, and right-click to access the context-sensitive menu.

The Extract Method dialog in Visual Studio Team System.