Interface: An interface is very similar to a class but with some changes!! As we all know, classes are by default internal and interfaces are by default public. An interface can only have a declaration but not a definition. An interface can only have methods, properties, indexers and events whereas a class can have everything.
The main use of an interface is to support Multiple Inheritance and it removes the classic diamond problem that we encountered in C++.
Classic Diamond Problem

In the preceding snapshot you can see that the D class objects will be confused about which method to call and raise an error in C++. Now we handle this problem with a C# interface but C# doesn't support Multiple Inheritance.


As in the preceding snapshots we can see that we got the desired result using of Multiple Inheritance but using an interface. As we mentioned above, there are two types of calling interface's method ; they are:
- Calling Implicit Interface Method
- Calling Explicit Interface Method
The Method defined without an Interface Name, i.e the way to calling an Implicit Interface method; a class can have only one Implicit Interface Method, as you can see in above snapshot, that First Display method is defined without interface Name and another is defined with the Interface name Ifc3.Display(), So this method definition tells to compiler that this Display() method is from Interface Ifc3, so its explicit calling of Interface Method and another one is implicit.
An interface called by an Interface Name is called an Explicit Interface; there can be many Explicit Interfaces in a class.
The following are some important things about interfaces:
- We cannot create an object of an interface, we can only create a reference or Interface Variable.
- An interface will have only abstract methods (method declaration).
- Interfaces supports Inheritance, Polymorphism (Overloading, Overriding (using the "new" keyword to hide the interface methods above)).
- We cannot create variables in an interface.
- Only Properties, Indexers, Methods and Events are allowed in an interface.
- A class can inherit multiple interfaces, which is also shown in the snapshot above.
- We cannot create any Access modifiers with Interface Members (like private, public, protected, internal, protected internal, virtual, override, static, abstract etc.)
- The new keyword is allowed in an interface.
- All methods of an interface must be defined in every derived class.
- An interface is good for small or medium level projects.
Abstract Class
Some points about an Abstract Class are:








Ahsan SiddiquePosted May 27, 2019, 2:30 AM
At least one abstract method is compulsory in an Abstract Class. This statement is not true.
Avnish KumarPosted Mar 5, 2018, 6:56 AM
Very nice explanation.........................................
Abhishek GuptaPosted Jan 4, 2018, 2:33 AM
Great Explanation. Keep it up
Er Pratap JadhwarPosted Jul 15, 2017, 12:10 PM
As Mr.yogendra has been explained in abstract class 3]Can have both concrete and abstract methods but at least one abstract method is compulsory in an Abstract Class.But" it is not true "there is no obligation that every abstract class must have at least one abstract method
Rajeesh MenothPosted Nov 8, 2015, 12:37 PM
Good Explanation
venkadesan perumalPosted Oct 23, 2015, 1:42 AM
Great
Gowtham RajamanickamPosted May 20, 2015, 1:24 AM
great...
Wu ChangJunPosted Jul 25, 2013, 5:37 AM
Words can show,An abstract class for class abstraction,Abstract interface for behavior?
Anil KumareditedPosted Apr 4, 2013, 1:52 PMEdited Apr 4, 2013, 1:53 PM
I don't think support of multiple inheritance as a problem. Each Language is written on some rules/grammars and C++ too. C++ also give you option to fully qualify your call like - YourSpecificClassName::FunctionName() (Compiler get confused if you omit fully qualified accessing and give you 'Ambiguous Access of FunctionName' exception.)