C # Programming Language Study Notes (4)

Source: Internet
Author: User
Chapter 4 Basic Concepts
1. protected internal (meaning protected or internal), which is selected by including both a protected and an internal modifier in the member declaration. the intuitive meaning of protected internal is "access limited to this program or types derived from the containing class."
Protected internal (which means protected or internal). In the member Declaration, both protected and internal modifiers are selected. Protected internal means "only thisProgramCan access"
2. namespaces implicitly have public declared accessibility. No access modifiers are allowed on namespace declarations.
Namespaces implicitly has a shared access level. Access Level modifiers are not allowed when namespaces are declared.
3. types declared in compilation units or namespaces can have public or internal declared accessibility and default to internal declared accessibility.
The types declared in the compilation unit or namespaces can be public or internal access level. The default value is internal access level.
4. class Members can have any of the five kinds of declared accessibility and default to private declared accessibility. (note that a type declared as a member of a class can have any of the five kinds of declared accessibility, but a type declared as a member of a namespace can have only public or internal declared accessibility .)
Class Members can have five access levels. The default value is private access. (Note that a class member can have one of the five access levels, but the type defined as the namespace member can only be public or internal access level ).
5. struct members can have public, internal, or private declared accessibility and default to private declared accessibility because structs are implicitly sealed. struct Members introduced in a struct (that is, not inherited by that struct) cannot have protected or protected internal declared accessibility. (Note that a type declared as a member of a struct can have public, internal, or private declared accessibility, but a type declared as a member of a namespace can have only public or internal declared accessibility .)
Structure members can have public, internal, and private access levels. The default value is private access level because the structure is implicitly closed. structure Type member (in other words, it is not the inheritance of that structure. A combination is not an inheritance. A combination cannot have a protected or protected internal access level. (note that the types declared as structure members can be public, internal, or private, but only public or internal access levels can be declared as namespace members ).
6. Interface members implicitly have public declared accessibility. No access modifiers are allowed on interface member declarations.
Enumeration members implicitly have public declared accessibility. No access modifiers are allowed on enumeration member declarations.
The interface and enumeration members are implicitly at the public access level. The interface and enumeration members cannot have access modifiers.
7. Note that anyRefAndOutParameter modifiers are part of a signature. Thus,F (INT)AndF (ref INT)Are unique signatures. Also, note that the return type andParamsModifier are not part of a signature, so it is not possible to overload solely based on the return type or on the exclusion sion or exclusion ofParamsModifier. As such, the declarations of the methodsF (INT)AndF (Params string [])Identified in the previous example result in a compile-time error.
Note that both the ref and out parameter modifiers are signature parts. therefore, F (INT) and F (ref INT) are both unique signatures. in addition, the return type and Params modifier are not part of the signature. Therefore, you cannot determine the overload Based on the return type or whether the Params modifier is included. therefore, F (INT) and F (Params string []) cause a compile-time error in the previous example.
The statements mentioned above that cause compilation errors are as follows: Interface Itest

{

Void F (); // F ()

Void F ( Int X ); // F (INT)

Void F ( Ref   Int X ); // F (ref INT)

Void F ( Int X, Int Y ); // F (INT, INT)

Int F ( String S ); // F (string)

Int F ( Int X ); // F (INT) Error

Void F ( String [] ); // F (string [])

Void F ( Params   String [] ); // F (string []) Error

}

8.a constant, field, property, event, or type introduced in a class or struct hides all base class members with the same name.
A method introduced in a class or struct hides all nonmethod base class members with the same name and all base class methods with the same signature (method name and parameter count, modifiers, and types ).
an indexer introduced in a class or struct hides all base class indexers with the same signature (parameter count and types ).
the rules governing operator declarations make it impossible for a derived class to declare an operator with the same signature as an operator in a base class. thus, operators never hide one another.

Constants, fields, attributes, events, or types in a class or structure hide members of the same name in the base class.
The class or structure method hides the non-method members with the same name in the base class and the method members with the same signature (method name and parameter quantity, form and type ).
The index in the class or structure hides the index (number and type of parameters) with the same signature in the base class)
The Declaration Rules of operators make it impossible to declare an operator with the same signature as the same class in the derived class. Therefore, operators will never overlap.
Chapter 4-9 describes types, variables, transformations, expressions, statements, and namespaces.

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.