Chapter 3
1. After the staff divides the assembly, they used to consider how the type works, how to contact. All representation of the type of the type (class, structure, enumeration, etc.) will eventually map to the CLR type definition.
2. CLR Type (CLR Type) is a named reusable abstract body. The CLR type describes the metadata of the CLR module that is also included as the CIL or native code required for the type of work.
3. Which of the fully qualified CLR class includes three parts: a program name, an optional namespace prefix, and a type name.
4. Public Type Systems are much wider than the types that can be processed in most programming languages. The CLI part submitted to ECMA is divided into a CTS subset that can be supported by all CLI-compatible language. This subset is called CLS (Common Language Specification, public language specification). Components strongly recommend developers to use CLS specifications to enhance the interviewability of components. The CLI defines a feature system.clsCompliant, which indicates that the compiler implements a CLS compliance check for all public members.
5. The CLR type is defined by zero or more members (Member). Each member of the type has its own access modifier to control the members' access. Access (PER-INSTANCE MEMBER) / PER-IPER, Type Member, Type Member, STATIC / Shared, etc.).
6. CTS has three basic types of members: fields, methods, and nested types. The field is a named storage unit that belongs to the type of declared. The method is a named operation that can be called and executed. Nested types are a simple accessibility. Other types of members (attributes, events) are methods that appear in the form of additional metadata.
7. Type field controls how memory is assigned. The CLR uses the type of field to determine how much memory is given to this type. The CLR will assign a memory for the Static field (when the type is loaded first).
8. When the CLR is assigned a type instance, the memory is allocated for the non-static field.
9. When allocating the memory, the CLR initializes the Static field and assigns the default value. The numeric type default is zero, the Boolean type defaults to false, the reference type is NULL.
10. By default, the exact memory layout is opaque. The CLR uses the virtual memory layout and reorders the fields frequently to optimize access and use.
11. Const is compiled, which will be contracted into all the places used in it (note the phenomenon of this), and the const field must be known when the initialization value is compiled; the Initonly field CLR will call it at the reference Value, the Initonly field can only assign a value in the declaration or constructor.
12. The CLR allows the method to use the [System.ParamarRayattribute] feature for the last parameter.
13. Since the compiler may have different characteristics, the clear overload is used as much as possible.
14. Nested types are often defined as an auxiliary object, such as an iterator, serializer.
15. Nested types can prevent pollution of namespaces. The Nested Type of the CLR is always declared as a static member, which is not affiliated to any particular example, and the nested type name is limited.
16. Nested types can do unrestricted access to private members of the declaration type.
17. Static field initialization order: Declaration à Static Construction Function (.cctor).
18. The CLR delays the call of the static initialization method to the first static field (BeforeFieldInit feature). Static initialization methods do not be called until the instance of this class is generated. 19. When the class and derived type are the same name, the CLR supports two basic strategies: hide-by-name and hidden by signature (Hide-by-signature). By adding the HIDEBYSIG metadata characteristics to the derived class to determine if it is determined. C # always hide by signature.
20. It is highly recommended that you want to call the virtual method in a Non-Sealed type constructor, because the part of the false method of the derived class has not been executed, so it may result in unforeseen problems.
21. Conformational order of derivatives: Initialization Parts Field à Construction Base class à call derived class ("Constructed Base Class" is a recursive process).
22. In order to ensure that the derived class correctly calls the constructor's constructor, the base class can be modified to INTERNAL, so that only the assembly that only writes can call the constructor.