Interfaces are special kind of type in C#, used to define the specifications (in terms of method signatures) that should be followed by its sub-types.
Interfaces, like abstract classes, cannot be instantiated. An interface can contain a signature of methods properties and indexers. An Interface is a type whose members are all public and abstract by default.
A class implementing the interface must provide the body for the members of the interface. A class can implement more than one interface, contrary to class-inheritance where you can inherit only one class. An interface itself can inherit other interfaces.
We can declare the reference of interface type and it can point to any class implementing it.
It is a convention in C# to prefix the name of interfaces with the uppercase "I" like IDisposable, ISerializable, IEnumerator etc.
No comments:
Post a Comment