ReSharper 8.0 Web Help

The Convert Abstract Class to Interface refactoring allows you to convert an abstract class to an interface. This is especially useful when you want a class to inherit from more than one abstract class, thus you need to convert one of them to an interface. The reverse functionality is available with the Convert Interface to Abstract Class refactoring.

To turn an abstract class into an interface
  1. Place the caret at the name of an abstract class in the editor, in the File Structure window, in Class View or Object Browser.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Convert | Abstract Class to Interface.
    • Choose Refactor | Convert | Abstract Class to Interface on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Convert Abstract Class to Interface.
  3. If no conflicts are identified, the abstract class is converted into an interface with the same name. At the same time, modifiers of methods are changed accordingly. Otherwise, resolve conflicts.

Consider the example below:
Refactorings__Convert_Abstract_Class_to_Interface_01
After applying the refactoring, the CacheManager class is converted into the CacheManager interface:
Refactorings__Convert_Abstract_Class_to_Interface_02

You can change the name of the newly formed interface using the Rename refactoring.


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

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.