Class attributes and interface attributes in C #

Source: Internet
Author: User

Class attributes

A class attribute is another form of a class member function. Its main task is to indirectly access data, the get block and set block definitions of the attribute must specify the data to be accessed. For automatic attributes, the compiler automatically creates the corresponding data fields and implements the get and set attributes.

 

Interface Properties

An interface can define attributes. An interface attribute can only have get or set blocks. If only set or get access is specified, this interface attribute indicates that, it only allows this type of access, which generates a constraint on the class implementation interface attribute, that is, when the class defines this interface attribute, the access permission cannot be greater than the permission specified in the interface. Although the class can supplement the set block or get block for this interface attribute, they cannot be defined as public. Note that no matter whether it is a function in an interface or an attribute in an interface, they are only interfaces. Therefore, for an attribute, it cannot implement get or set blocks.

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.