Difference between Interface and Abstract class in C#

This is the commonly asked question by the interviewers that what is the difference between Interface and Abstract class.
You can also read these articals that is interface and abstract class in details through this link Interface and Abstract class.

Please go through the article to understand the concept.






Table of Differences

Interface Abstract Class
Interface contain methods / properties / events / indexers(only declaration). They are created with the help of ‘interface’ keyword. Any derived class must have to implement all the functions declared in interface. Abstract Classes are the classes that contain abstract fields – methods / properties(only declaration) or non abstract methods(with definition). They are created with the help of ‘abstract’ keyword. The abstract methods do not provide any concrete definition but required a derived class to implement its abstract methods.
It can not contain constructor Abstract class can contain constructor
Interface can not contain data member Abstract class can contain data member
Interface contains only declaration of functions etc . Abstract class can contain only declaration or both declaration and definition also.
Contains only incomplete function etc Can contain both complete as well as incomplete function etc
It support multiple inheritance. It can not support multiple inheritance
It can’t use any access modifier , by default public It can use any access modifier.
Any class inheriting the Interface , it must to have to implement all the function . Any class inheriting the abstract , it may or may not to have to implement all function.
interface imyapp
{
void sum(int a, int b); // only declaration
}

class index : imyapp
{
imyapp myapp = new index();
public void sum(int a, int b) // must have to implement in derived class
{
}
}

abstract class X
{
public void methodA()
{ // definition of A();
}
public abstract void B(); // only declared
public abstract void C(); // only declared
}
class Y : X
{
public override void B()
{ //here provide the implementation code
}
public override void C()
{ // body of C()
}
}


Above are the basic differences between interface and abstract class variables.