Understanding of the interface (interface) in C # _c# tutorial

Source: Internet
Author: User
. are "virtual" cannot be instantiated, which is why the interface cannot contain a field-member variable.
2. Because the interface is virtual, so the index within the interface, attributes, time and so can only have declarations, but not in the interface implementation, how to implement the derivation of the interface or derived classes.
3. All have the nature of the template, if an interface or class inherits from an interface, it will automatically have the characteristics of the integrator (including indexes, attributes, functions, practices, etc.).
4. Interfaces support multiple inheritance, whereas in C #, classes support a single inheritance, and interfaces actually represent a load capacity.
The following is a simple definition of an interface:
Copy Code code as follows:

Interface
SampInterface1
{
String
this[INT index]
{
Get
Set
}

Event EventHandler event;
void find (int value);
Note that there is no
{
}
String Po
Int
{
Get
Set
}

}

The above interface defines an index this, a practice event, a method find and a property point.
Copy Code code as follows:

public interface sampineterface:sampineterface1{
pravite int a=1;
void find (int value)
{
A+=value;
}
Event EventHandler event;
protected void OnEvent ()
{
if (event=null)
{return Event, this. System.EventAgrs.Empty;)}
}
}

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.