The default modifier in C,

Source: Internet
Author: User

The default modifier in C,

Refer to Default visibility for C # classes and members (fields, methods, etc )?

Classes and structs that are declared directly within a namespace (in other words, that are not nested within other classes or structs) can be either public or internal. internal is the default if no access modifier is specified.

Directly declare the classes and struct in the namespace. The default value is internal.

 

The access level for class members and struct members, including nested classes and structs, is private by default.

Class and struct members, including embedded classes and struct. The default value is private.

 

Interfaces default to internal access.

The interface is internal by default.

 

Delegates behave like classes and structs. By default, they have internal access when declared directly within a namespace, and private access when nested.

The delegate is similar to the class and struct. Directly declare that the access permission in the namespace is internal by default. If embedded, it is private.

 

Top-level types, which are not nested in other types, can only have internal or public accessibility. The default accessibility for these types is internal.

In summary, the highest level of type (not embedded in other types) can only have internal and public access permissions. The default access permission for these types is internal.

 

However, for Embedded types
And for nested types:
Members of Default member accessibility
--------------------------------------
Enum public // The enum member has the public access permission.
Class private // a member of the class, which is the access permission of private by default
Interface public // interface member. The default value is public access permission.
Struct private // a struct member. Similar to class, the default access permission is private.

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.