Interface, personal understanding

Source: Internet
Author: User
Tags iusb

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.