1. After the staff has divided the assembly, they spend most of their time thinking about how the type works and how it is contacted. The build (class, struct, enum, etc.) of all the presentation types will eventually be mapped to the CLR's type definition.
2. CLR type (CLR type) is a named reusable abstract body. The description of the CLR type is stored in the metadata of the CLR module, which also contains the CIL or native code required for the type of work.
3. Fully qualified CLR class which name includes three parts: assembly name, optional namespace prefix, and type name.
4. The common type system is much wider than the type that most programming languages can handle. The part of the CLI submitted to ECMA is divided into a subset of the CTS, which is supported by all CLI-compatible languages. This subset is called the CLS (Common Language specification, the Common Language specification). Component strongly recommends that developers use CLS-compliant specifications to enhance the accessibility of components. The CLI defines an attribute system.clscompliant that instructs the compiler to enforce CLS compliance checks on all public members.
5. A CLR type definition consists of 0 or more members (member). Each member of a type has its own access modifier (access modifier) that controls access to the member. Access by instance (Per-instance member)/By Type (Per-type member, that is, static/shared, etc.).
6. The CTS has three basic types of Members: Fields, methods, and nested types. A field is a named storage unit that is subordinate to the declared type. Method is a named operation that can be invoked and executed. A nested type is a simple auxiliary type. Other types of members (properties, events) are methods that appear in the form of additional metadata.
7. The type of field controls how memory is allocated. The CLR uses a field of type to determine how much memory is allocated to this type. The CLR assigns the static field one memory (when the type is first loaded).
8. Each time the CLR allocates a type instance, memory is allocated for the Non-static field.
9. When allocating memory, the CLR initializes the static field and assigns a default value. The numeric type defaults to zero, the Boolean type defaults to False, and the reference type is null.
10. By default, the exact memory layout is opaque. The CLR uses virtual memory layouts and frequently reorder fields to optimize access and use.
Const will be inline with all the places where it is used (note the phenomenon of doing so) at compile time, the Const field must be known at compile time by the initonly field, the CLR will call its value at the reference, and the initonly field can only be assigned in the declaration or constructor.
The CLR allows methods to use the [System.paramarrayattribute] attribute for the last parameter.
13. Because the compiler may have different characteristics, try to use explicit overloads.
14. Nested types are often defined as auxiliary objects, such as iterators, serializers.
15. Nested types can prevent the contamination of namespaces. The nested type of the CLR is always declared as a static member and is not subordinate to any particular instance, and the name of the nested type has an external type name qualification.
16. Nested types can do unrestricted access to private members of declared types.
17. Static field initialization order: declaring à static constructor (. cctor).
The CLR defers calls to the static initialization method until the first static field is accessed (the BeforeFieldInit attribute). The static initialization method is not necessarily invoked before the instance of this class is generated.
19. When a method with the same name exists for a base type and a derived type, the CLR supports two basic policies: hiding by name (Hide-by-name) and by signature (hide-by-signature). determined by adding the Hidebysig metadata attribute to the method of the derived class. C # is always hidden by signature.
20. It is strongly recommended that you do not invoke a virtual method in a constructor of a non-sealed type, because the part of the virtual method of the derived class has not yet been executed, and may cause unforeseen problems
21. Order of execution when constructing derived classes: Initialize derived class field à construct base class à invoke a derived class ("construct a base class" is a recursive procedure).
22. In order to ensure that a derived class correctly invokes the constructor of a base class, the constructor of the base class can be decorated to internal, which guarantees that only the assembly that is written by itself can invoke the constructor.
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