This website may use cookies. More info. That's Fine x
Welcome Login

Visual studio: Refactoring: Extract method

Extract Method is a refactoring operation that provides an easy way to create a new method from a code fragment in an existing member.


Using 'Extract Method', you can create a new method by extracting a selection of code from inside the code block of an existing member.

The new extracted method contains the selected code, and the selected code in the existing member is replaced with a call to the new method.

Turning a fragment of code into its own method lets you quickly and accurately reorganize code for better reuse and readability.


To use extract method refactoring:


1. Select code you want to extract into a new method.

2. Right click > Refactor > Extract Method... > add a new method name > Click OK.












For more information, see here.

Created on: Tuesday, August 4, 2015 by Andrew Sin