Abstract Class Versus Interface

Interfaces are specifications defining the type of behaviors a class must implement. They are contracts a class uses to allow other classes to interact with it in a well-defined and anticipated manner. Interfaces define an explicit definition of how classes should interact.

Abstract classes are a unit of abstraction, whereas interfaces define further specification. Abstract class members may contain implementations. The exception is when an abstract class member has an abstract modifier. Derived classes must implement abstract class members with an abstract class modifier, but they don't have to implement any other method declared virtual. On the other hand, classes inheriting an interface must implement every ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.