Application of public,private,internal and other modifiers in C #

Source: Internet
Author: User

-----------------------from-Drift blog----------------------

Character is used to qualify a type and a declaration of a type member, there are 13 modifiers in C # that can be divided into three parts by function: Access modifiers, class modifiers, and member modifiers.

Access modifiers:

Public: Access is unrestricted.

Private: Only classes that contain that member can be accessed.

Internal: Only current projects can be accessed.

Protected: Only the class that contains the member and the inherited class can be accessed.

Class Modifiers:

Abstract: Can be indicated that a class can only serve as a base class for other classes.

Sealed: Indicates that a class cannot be inherited.

Member Modifiers:

Abstract: Indicates that the method or property is not implemented.

Const: Specifies that the value of a field or local variable cannot be altered.

Event: Declares an event.

extern: Indicates that the method is implemented externally.

Override: A new implementation of an inherited member of the radical class.

ReadOnly: Indicates that a field can be assigned only at declaration time and within the same class.

Static: Indicates that a member belongs to the type itself, not to a particular object.

Virtual: Indicates that an implementation of a method or accessor can be overridden in an inherited class.

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.