I have summarized four points on the interface. The USB interface is the most common interface. Here we will take the USB interface as an example!
Public interface iusb: idisposable {
Void outputfile (); // read the file
Void inputfile (); // write the file
}
Public class phone: iusb {
Public void outputfile () {Throw new notimplementedexception ();}
Public void inputfile () {Throw new notimplementedexception ();}
Public void dispose () {Throw new notimplementedexception ();}
}
1. The iusb interface is equivalent to the USB data cable pin. The iusb interface is equivalent to adding the same pin on the device as the USB data cable;
2. How to Write the method body on your own? It is best not to modify the function without any need to implement this interface. You can restrict or expand this function, for example, some mobile phones can use the USB data cable to connect two mobile phones to charge another mobile phone. Some mobile phones can only charge other mobile phones, but they cannot charge others;
3: iusb USB = new phone (); assign the created instance to the parent variable. The variable name is equivalent to the data line, with this type of variable, you can call the class method that implements this interface, which shields the type differences and achieves the polymorphism effect, this is equivalent to connecting different devices such as mobile phones and MP3 with a data cable;
4: As long as you know some digital product hardware or network communication knowledge, you should know that the data line connection settings depend on the Several pins for data transmission, the shape style of the interface is only convenient for users to plug and unplug connections. Just like most of the conversion interfaces, the line is reorganized and connected to the interface of another shape;