Abstract Base Vs Interface
An Abstract class without any implementation just looks like an Interface; however there are lot of differences than similarities between an Abstract class and an Interface.
- We cannot make instance of abstract class.
- An abstract class is only to be sub-classed (inherited from).
- In other words, it only allows other classes to inherit from it but cannot be instantiated.
An interface is not a class.
An interface has no implementation; it only has the signature.
It just the definition of the methods without the body.
Similarity between Abstract class and Interface:
They act as a contract that is used to define hierarchies for all their subclasses.
A class can implement more than one interface but can only inherit from one abstract class.
Since C# doesn't support multiple inheritance, interfaces are used to implement multiple inheritance.
Sample Code Download: AbstractBase_Vs_Interface.zip