Three main features of object-oriented design: 3. encapsulation and object-oriented

Source: Internet
Author: User

Three main features of object-oriented design: 3. encapsulation and object-oriented

Add a new assembly:

Right-click solution-add-new project-class library

Select Main project-reference-right-click to add reference

Using assembly

 

Class access modifier:

The class has two levels of access: public and internal.

Classes marked as Public can be accessed by any assembly in the system;

The class marked as internal can only be seen by the class in its own assembly. The default value is internal access level.

 

Access modifier of members

1. All explicitly declared members in the class declaration are mutually visible, regardless of their accessibility instructions

2. You must specify the access level for each member. If the access level of a Member is not specified, its implicit access level is private.

3. A member cannot have higher access than its class.

Private-it can only be accessed by members of its own class.

Internal-visible to all classes inside the Assembly, but invisible to classes outside the Assembly

Protected-allows the class of the derived class to access this Member, even if the class that inherits this class from outside the Assembly can access this member.

Protected internal-visible to all classes that inherit the class and the classes inside all the Assembly

Public-classes inside and outside the Assembly can be accessed

 

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.