During this week's class, the teacher told us some knowledge about the interface (Interface). Let's go through the actual operation to review:
First we want to understand what an interface is, similar to the abstract class we mentioned earlier, where abstract classes are often the base class for a series of derived classes, and interfaces can implement multiple inheritance.
Next we can look at the implementation syntax of the interface:
Nature [Access modifier word]interface interface Name [: Base list]{interface body}
This is where the interface name usually begins with uppercase.
Let's try to implement a simple interface:
usingSystem;namespacesimpleinterface{InterfaceIstorabale {voidRead (); voidWrite (); //This method is public and does not implement these methods here. } Public classdocument:istorable {//A class that implements an interface is created PublicDocument (strings) {...} Public voidRead () {//implementing the Read method ... } Public voidWrite () {//implementing the Write Method ... }
In the above code, we have created an interface named Istorable and implemented this interface through the document class.
Liam's C # learning Journey (iv): interface