Differences between interface and abstract class in c#
In this article, I have explained the difference between an Abstract Class and an Interface in C#.
It is little confusing when we are discussing about an abstract class and interface in C#. Some similarities and differences between an interface and an abstract class are following.
||Interface can implement multiple inheritance
||It can not
||An interface has no implementation
An abstract class can provide complete, default code and/or just the details that have to be overridden.
||All interfaces are by default public and abstract
||An abstract class can contain access modifiers
||Requires more time to find the actual method in the corresponding classes.
||If various implementations only share method signatures then it is better to use Interfaces.
||If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.
|Fields and Constants
||No fields can be defined in interfaces
||An abstract class can have fields and constrants defined