ReSharper Web Help

The Extract Class refactoring allows you to extract a new class with members of some existing class. For example, this refactoring is useful when you need to replace a single class that is responsible for multiple tasks with several classes each having a single responsibility.

To extract a class
  1. Place the caret at the name of a class in the editor or select the class in the File Structure window, in Object Browser or in Class View.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Extract Class.
    • Right-click the type, then click Refactor | Extract Class on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Extract Class.
  3. The Extract Class dialog box opens. Type a name for a new class in the Extracted class text box.
  4. Specify names for references to the extracted class in the Reference to extracted text box and to the existing class in the Reference to source text box or leave the suggested ones.
  5. Select members to be extracted into the class. ReSharper may suggest to extract additional members by marking them with Extract word. Click Extract all suggested members to extract all of them.
  6. Specify the location for the extracted class:
    • Click same file as the source class to place the new class in the same file as the original class.
    • Click its own file to place the new class in a separate file.
  7. Click Next to apply the refactoring. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, resolve conflicts.

This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available feature_available

Tip

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.