C # access Modifiers

Source: Internet
Author: User

Access modifiers in C #:

①private, private access modifiers, members decorated by the private access modifier are accessible only within the current class and are not accessible anywhere else. The members of the class do not use modifiers, and the default is private.

②protected, which indicates that the current class can be accessed internally, and that all subclasses are accessible internally.

③internal, inside the current assembly. The default access modifier for a class is internal.

Note: The protected and internal access modifiers do not matter which one is more "accessible" because the judging criteria are different.

Protected only see if it is inside the current class or within all subclasses, regardless of whether it is in the same assembly.

The internal only depends on whether it is within an assembly, regardless of whether it has an inheritance relationship.

④protected internal, which features both protected and internal, within the current class, inside all subclasses, within the current assembly can be accessed.

⑤public, there is no limit anywhere you can access it.

All types that are directly defined in the namespace, such as classes, delegates, enumerations, structures ... The access modifier can only be public or internal.

C # access Modifiers

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.