ReSharper Help  

Convert Interface to Abstract Class

The Convert Interface to Abstract Method refactoring allows you to simplify a local hierarchical dependency among a set of classes and interfaces. This is especially useful when you no longer want a class to implement an interface, thus it makes sense to convert the interface to an abstract class and bring its methods into the new abstract class.

The reverse functionality is also possible with the Convert Abstract Class to Interface refactoring.

To turn a suitable interface into an abstract class, do either of the following:

If no conflicts are present, the interface is converted into an abstract class of the same name. At the same time, modifiers of methods are changed accordingly.

Consider the following example:

After we convert ICodeFormatter to an abstract class, the code looks as follows:

You can change the name of the newly formed abstract class using the Rename Type refactoring.

Note: A number of possible conflicts may occur which can affect the use of Convert Interface to Abstract Method refactoring. Some of them can be circumvented while others will prevent the use of this refactoring.

See Also

Refactoring Code | Convert Abstract Class to Interface