Interface and abstract class are almost same. That’s why we may confused. But they are not same, have some difference. This article explains the difference between abstract and interface. Summary of the article:
- What is Abstract Class?
- What is Interface?
- Interface Vs Abstract Class
What is Abstract Class?
Abstract class is a class that contain abstract (incomplete) and non abstract (complete) both type of member and it cannot be instantiated. It is one of the essential behaviors provided by .NET technology.
What is Interface?
Interface is a template which contains only the signatures of methods,events or delegates. It has no implementation and the implementation is done by the class which implements the interface.
Interface Vs Abstract Class
Difference between abstract class and interface is given bellow:
- It support multiple inheritance .
- It doesn’t contains Data Member.
- It doesn’t contains Constructors.
- It contains only abstract (incomplete) member.
- It cannot have access modifiers by default everything is assumed as public.
- Member of interface cannot be Static.
- It does not support multiple inheritances.
- It contains Data Member.
- It contains Constructors.
- It contains both abstract (incomplete) and non abstract (complete) member.
- It can contain access modifiers for the subs, functions, properties
- Complete member of abstract class can be Static.
We should have a clear concept on interface and abstract class. We must need to know when to use interface and when to use abstract class. That’s all about abstract class vs interface.