Liam's C # learning Journey (iv): interface

Source: Internet
Author: User

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

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.