. NET Learning 3rd-quarter C # object-oriented interface

Source: Internet
Author: User

. Net Video Learning 3rd-quarter C # Object-oriented

Object-oriented interface

A class in C + + can inherit from more than one class, but is not allowed in C #. So if you want to implement similar operations, you need an interface, the keyword interface

 Public class person{}  Public Interface iable{    void  Test ();}  Public class student:person,iable{    void  Test ()    {        Console.WriteLine ("  test");}    }

The interface name usually begins with I able end.

A method in an interface can have a return value, but a member in an interface cannot be decorated by an access modifier, the default is public (and the members in the class are defaulted by default, members of the class are private by default), and interface members are not allowed to be defined (abstract methods of abstract classes cannot be defined)---cannot have method bodies.

Property has only automatic properties. (Write-only properties, no fields, fields are automatically generated, loss of protected field function because the get and set of automatic attributes have no method body)

. NET Learning 3rd-quarter C # object-oriented 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.