Introduction to the ASP. NET modifier (about public, private, protected, internal)

Source: Internet
Author: User

1.private modifier

The private modifier is used to set the access rights of a class or class member only to the inside of the owning class.
Private is also known as a private modifier. Sometimes when you need access to a private class member, you can read or modify it through the get and set accessors.

2.protected modifier

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

3.internal modifier

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

4.public modifier

The public modifier is publicly accessible and has no restrictions on access to the code.
In most cases, the public modifier must be used with caution, because abuse affects the encapsulation of classes and poses a security risk.

Accessibility implications of claims
Public access is not restricted
Protected access is limited to types that contain or derive 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

Introduction to the ASP. NET modifier (about public, private, protected, internal)

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.