Trusted answers to developer questions

Abstract class vs. Interface in C#

Get Started With Data Science

Learn the fundamentals of Data Science with this free course. Future-proof your career by adding Data Science skills to your toolkit — or prepare to land a job in AI, Machine Learning, or Data Analysis.

Abstract class

Interface

1. Abstraction

Abstraction is one of the most powerful features of object-oriented programming. It is a way to provide users with only the most relevant and essential information​​ while hiding the rest.

Abstract classes don’t provide complete abstraction – they can have concrete methods along with the abstract ones.

Interfaces provide complete abstraction; however, they can not have concrete methods.

svg viewer

2. Constructors

A constructor is the special method of a class ​used to initialize the objects of the class.

svg viewer

Abstract classes can have different types of constructors.

Interfaces cannot have constructors.

3. Multiple inheritance

Inheritance is another feature of object-oriented programming where a particular class can derive from a base class. Multiple inheritance allows the extension of more than one base class in a derived class.

Abstract classes do not support multiple inheritance.

Interfaces support multiple inheritance.

RELATED TAGS

c#
abstract class
interface
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?