Types of Interface in C#
Interface in C#:
In C#, An interface is a reference type, it is basically a kind of class.
Properties of Interface:
1. All the members of an interface are implicitly public and abstract.
2. An interface can’t contain constant fields, constructors and destructors.
3. Its members can’t be declared static.
4. An interface can inherit multiple interfaces.
Defining an Interface:
An interface can obtain one or more methods, properties, indexers and events. It has the following syntax:
interface { member declaration; }
Example:
interface Show { void Display(); }
Extending an Interface:
Like classes, interfaces can also be extended. That is an interface that can be sub-interfaced from other interfaces. The new sub-interface will inherit all the members of the super-interface like sub-classes. It has the following syntax:
interface name2: name1 { members of name2; }
Example:
interface Addition { int Add(int a, int b); } interface Compute: Addition // Extending the interface { int Multi(int a, int b); }