C # class member access modifier

Source: Internet
Author: User

 

The access modifier is used to specify the accessibility of class members. The C # access modifiers include private, protected, public, and internal.

Private declares Private Members. Private Data members can only be used and modified by functions in the class. Private function members can only be called by functions in the class. Although the derived classes inherit the Private Members of the base class, they cannot be accessed directly and can only be accessed through the public members of the base class.

Protected declares to protect members. To protect data members, they can only be used and modified by functions inside the class and derived classes. To protect function members, they can only be called by functions inside the class and derived classes.

Public declares public members. The public function members of a class can be called by external programs of the class, and the public data members of the class can be directly used by external programs of the class. A public function is actually an interface for communication between a class and an external function. by calling a public function, an external function modifies the private and protected members of a class in a preset way.

Internal declares that internal members can only be accessed in files in the same Assembly. They are generally the same application or library ).

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.