ReSharper 2017.3 Help

Convert Interface to Abstract Class refactoring

ReSharper | Refactor | Convert | Method to Indexer…
ReSharper_Function2Indexer

This refactoring converts interfaces into abstract classes thus helping you quickly change hierarchical dependency among a set of classes and interfaces.

Consider the following example:

Before refactoringAfter refactoring
interface Shape { double Area { get; } void Draw(); } class Circle : Shape { private readonly int radius; public double Area { get { return Math.PI*Math.Pow(radius, 2); } } public void Draw() { //do something } }
abstract class Shape { public abstract double Area { get; } public abstract void Draw(); } class Circle : Shape { private readonly int radius; public override double Area { get { return Math.PI*Math.Pow(radius, 2); } } public override void Draw() { //do something } }

To turn a suitable interface into an abstract class

This feature is supported in the following languages and technologies:

Language: C# Language: VB.NET Language: C++ Language: HTML Language: ASP.NET Language: Razor Language: JavaScript Language: TypeScript Language: CSS Language: XML Language: XAML Language: Resx Language: Build Scripts Language: Protobuf Language: JSON
Feature is available Feature is available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available Feature is not available

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.

Last modified: 22 February 2018

See Also