Difference Between Abstract class and Interface in c#

Posted By : Bipul Kumar Tiwari,

Abstract class and Interface are similar concepts. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. where Interface is a type which contains only the signatures of methods, delegates or events and it has no implementation. The major difference between abstract and interface are:


Interface Abstract Class
Interface support multiple inheritance and a class may inherit several interfaces. Abstract class does not support multiple inheritance and a class may inherit only one abstract class.
Interface can only inherit from another Interface. abstract class can inherit from a class and one or more interfaces.
Interface cannot contain constructors or destructors. abstract class can contain constructors or destructors.
In interface No fields can be defined. abstract class can contain fields. 
If we add a new method to an Interface then we have to track down all the implementations of theinterface and define implementation for the new method. If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.
An interface cannot have access modifiers by default everything is assumed as public. An abstract class can contain access modifiers for the subs, functions and properties.
Member of interface can not be Static . Only Complete Member of abstract class can be Static .


Related Articles

 

About the Author

author
Its me BIPUL who is logically minded creative at heart , a good communicator , a self taught full stack developer. I constantly focuses on my thinking , reading , collecting and creating my work in a order to enhance my skills.

I discover new dimensions for growing bussiness with a proven record in creating database and programming. I have a strong technical skills as well as strong interpersonal skills. Read more...
 

Browse By Category

Popular Articles