#445 – Differences Between an Interface and an Abstract Class

An interface provides a list of members, without an implementation, that a class can choose to implement.  This is similar to an abstract class, which may include abstract methods that have no implementation in the abstract class, but might also include an implementation for some of its members.

One difference is that an abstract class might include some members that are fully implemented in the abstract class.  Interfaces can’t include the implementations of any of their members.  An interface just describes what a class does, while an abstract class may define how something is done.

Another difference is that a class can inherit from multiple interfaces, but can inherit from at most one base class.  Abstract classes allow you to treat an object polymorphically, based on any of the classes in its inheritance chain.  Interfaces let you treat a class polymorphically, based on any of the interfaces it implements.

Advertisement

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #445 – Differences Between an Interface and an Abstract Class

  1. Pingback: #446 – Deciding Between an Abstract Class and an Interface « 2,000 Things You Should Know About C#

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: