C # Learning process--interface

Source: Internet
Author: User

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

Related Article

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.