Introduction to ASP.net modifiers (about public, private, protected, internal) _ Practical Tips

Source: Internet
Author: User
Tags modifier modifiers

1.private modifier

The private modifier is used to set the access rights of a class or class member to the internal of the owning class only.
Private is also known as a proprietary modifier. When you need to access a private class member at some point, you can read or modify it through get and set accessors.

2.protected modifier

The protected modifier is used to set the access rights of a class or class member to only the internal of the owning class and subclass.

3.internal modifier

The internal modifier modifies the access rights of the class or class member within the same assembly, and the C # default class access modifier is internal.

4.public modifier

The public modifier is common access, and there is no restriction on access to the code.
In most cases, the public modifier must be used sparingly, because abuse affects the encapsulation of the class and poses a security risk.

The accessibility meaning of the Declaration
Public access is unrestricted
Protected access is limited to the containing class or types derived from the containing class
Internal access is limited to the current project
Protected internal access is limited to the current project or type derived from the containing class
Private access is limited to the containing type

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.