|
|
|
Similar ArticlesMost ReadTop RatedLatest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Introduction
An interface looks like a class, but
has no implementation. The only thing it contains are definitions of events,
indexers, methods and/or properties. The reason interfaces only provide
definitions is because they are inherited by classes and structs, which must
provide an implementation for each interface member defined.
Interface characteristics
- An interface
defines only the properties and method signatures and not the actual
implementation. In a class declaration we implement fields, properties,
methods and events. In an interface we just define what properties/methods
the class should have.
- Requires that
classes which implement an interface must "honour" the property
and method signatures. Basically are like contracts for classes. Classes
which implement an interface must implement the methods and the properties
of the interface.
- Many classes can
implement a particular interface method, in their own way
- An interface may
inherit from multiple base interfaces
- A class may
implement-inherit from multiple interfaces
- A C# class may
only inherit from one class
|