ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Convert Abstract Class to Interface refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Convert | Abstract Class to Interface…

To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_Abstract2Interface command.

This refactoring allows you to convert an abstract class to an interface. This can be useful when you want a class to inherit from more than one abstract classes — then you can easily convert one of them to an interface.

Consider the example below. After applying the refactoring, a class is converted into an interface:

By default, the naming style for interfaces requires interface names to start with I. Therefore, if you did not change the settings, the interface name will be highlighted as inconsistently named. Just press Alt+Enter and use the corresponding quick-fix to  rename the interface.

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 details specific to other languages, see corresponding topics in the ReSharper by language section.