Home > C# > Interface in C#

Interface in C#

This post was most recently updated on August 5th, 2024

An interface is a contract contains methods, properties, events and indexers. A class or structure that implements the interface must implement all the members of the interface. The interface defines ‘what’ part of the contract and classes or structure that implements the interface defines ‘how’ part of the contract.

Methods, properties, events are the members of the interface. Interface contains only the declaration of the members. The responsibility of derive class or structure to define all members specified in interface definition.

.Net does not support multiple inheritance, but one can achieve this objective by implementing multiple interfaces to class.

In short, interface is an agreement or contract that is forced a developer to implement all the declaration and define them in class or structure.

How to declare Interfaces?

Output:

Output
Interface Output
This Article is TAGGED in . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">