Accessibility level C # Modifier

Source: Internet
Author: User

You can use the public, protected, internal, or private modifier to specify one of the following declared access levels for members.

Http://keleyi.com/a/bjad/3ccfqh95.htm

Declared accessibility

Description

Public

Access is unrestricted.

Protected

Access is limited to include classes or types derived from include classes.

Internal

Access is limited to the current Assembly.

Protected internal

Access is limited to the current Assembly or type derived from the include class.

Private

Access is limited to the include type.

One member or type can only have one access modifier, except when the protectedinternal combination is used.

Access modifiers are not allowed in the namespace. The namespace has no access restrictions.

Only the accessibility of some declarations is allowed according to the context in which the member declaration appears. If no access modifier is specified in the member declaration, the default accessibility is used.

The accessibility of top-level types not nested in other types can only be internal or public. The default accessibility of these types is internal.

The nested type is a member of another type, which can have the accessibility declared as shown in the following table.

 

Belong

Default accessible members

The declared accessibility allowed by this Member

Enum

Public

None

Class

Private

Public

Protected

Internal

Private

Protected internal

Interface

Public

None

Struct

Private

Public

Internal

Private

The accessibility of the nested type depends on its accessible domain, which is determined by the declared member accessibility and directly including accessible domains. However, the accessible domains of the nested type cannot exceed the accessible domains of the contained 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.