What is a Interface?
The Interface is a contract that describes the signature of the functionality. So when a class is implementing a interface it says to the outer world, that it provides specific behavior. For example if a class is implementing Idisposable interface which means it has a functionality to release unmanaged resources. Now all the external objects using this class know that it has contract by which it can dispose unused unmanaged objects.
1. The Single Class can implement multiple interfaces.
2. If a class implements the interface then it has to provide implementation to all its methods.
In the sample there are 2 files. One has the definition of interface and other class implements the interface. Below is the source code "IInterface" is the interface and "ClsDosomething" implements the "IInterface". The sample just displays a simple message box.
Public Interface IInterFace
Public Class ClsDoSomething
Public Sub DoSomething() Implements WindowsInterFace.IInterFace.DoSomething MsgBox("Interface implemented") End Sub
Figure:-Interface in action