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.
- Place the caret at the name of an abstract class in the editor, in the File Structure window, in Class View or Object Browser.
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.
- 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:
After applying the refactoring, the CacheManager class is converted into the CacheManager interface:
You can change the name of the newly formed interface using the Rename refactoring.
This feature is supported in the following languages/technologies:
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.