ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Extract Class refactoring

Last modified: 23 September 2024

This refactoring allows you to move members of an existing class to a new class. It will be helpful when you need to replace a single class that is responsible for multiple tasks with several classes each having a single responsibility.

ReSharper will automatically create a reference field that will provide access to the newly created class. If necessary, you can also leave the extracted members in the original class as copies or so that the implementation is delegated to the same members in the new class.

In the example below, we extract the LogError method into the new Logger class

ReSharper. Extract class refactoring

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.