This article is about consolidating basic knowledge
The concept of interface:
interface contains only methods, properties, eventsor Indexerthe signature methods , Properties , events or indexers . " > The class or struct that implements the interface must implement the interface members specified in the interface definition.
Reference Link:
Http://www.cnblogs.com/michaelxu/archive/2007/03/29/692021.html
A simple example is provided in MSDN.
Interfaceisampleinterface{voidSampleMethod ();}classimplementationclass:isampleinterface{//Explicit interface member implementation: voidIsampleinterface.samplemethod () {//Method implementation. } Static voidMain () {//Declare an interface instance.ISampleInterface obj =NewImplementationClass (); //Call the member.obj. SampleMethod (); }}
Here, the interface only declares a method signature, the Implementclass implementation class inherits this interface, which means that the implementation class must implement all the members of this interface
Finally, an interface instance is declared at the time of invocation, the object derived from the interface is assigned to the interface type, and finally the method of the derived class is executed by the interface instance.
C # interface