C # interface

Source: Internet
Author: User

This article is about consolidating basic knowledge

The concept of interface:

interface contains only methods, properties, eventsor Indexerthe signature methods , Properties , events or indexers . " >   The class or struct that implements the interface must implement the interface members specified in the interface definition.

Reference Link:

Http://www.cnblogs.com/michaelxu/archive/2007/03/29/692021.html

A simple example is provided in MSDN.

Interfaceisampleinterface{voidSampleMethod ();}classimplementationclass:isampleinterface{//Explicit interface member implementation:    voidIsampleinterface.samplemethod () {//Method implementation.    }    Static voidMain () {//Declare an interface instance.ISampleInterface obj =NewImplementationClass (); //Call the member.obj.    SampleMethod (); }}

Here, the interface only declares a method signature, the Implementclass implementation class inherits this interface, which means that the implementation class must implement all the members of this interface

Finally, an interface instance is declared at the time of invocation, the object derived from the interface is assigned to the interface type, and finally the method of the derived class is executed by the interface instance.

C # 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.