We learned the interface in the last lesson.
In terms of creating a contract between a class and its customers, an interface is an alternative to an abstract class, and the difference between them is that abstract classes are often the base class for a series of derived classes, and the role of an interface is to mix contracts with other inheritance trees.
The keyword interface is the name of the interface. The first letter of the generic interface name is I (but not necessarily imaginary).
The interface topic describes the methods, properties, and so on that the implementation class must implement.
Use a simple interface:
usingSystemnamespacesimpleinterface{Interfaceistorable {//No access modifier word, method is public//not implemented voidRead (); voidWrite (Objectobj); intstatus{Get;Set; } } //to create a class that implements the Istorable interface Public classdocument:istorable { PublicDocument (strings) {} Public voidRead () {//implementing the Read method } Public voidWrite () {//implementing the Write Method } Public intStatus {Get;Set; } } }
C # Learning process--interface