Three types of construction methods:
Instance constructor (reference type): the instance constructor can never be inherited (so there are no modifiers before the method), and if the class's modifier is static (sealed and abstract), the compiler does not generate a default constructor in the class's definition at all.
Important cognition: To make the code "verifiable," the class's instance constructor must call the base class's constructor before accessing any fields inherited from the base class. If the constructor of a derived class does not appear to call a base class constructor, the C # compiler automatically generates a call to the default base class constructor.
The fields declared in the class are actually initialized in the code that is converted to the constructor in the compiler. If there are 3 fields and 3 constructors in a class, then the compiler actually generates three times the code that initializes 3 fields-once per constructor.
Instance constructor (value type): The C # compiler does not allow a value type to define a parameterless constructor (can be a parameter).
Type constructors (static constructors): You can define only one, no parameters, and common constructors to coexist, to set the initial state of the type instance. Its invocation is the responsibility of the CLR. It executes only once (multi-threaded).
Extension methods:
C # extension method: Allows you to define a static method and invoke it using the syntax of the instance method. (just add the This keyword before the first parameter of the method)
Parameters:
When declaring a method's parameter type, you should try to specify the weakest type, preferably an interface rather than a base class. (ref, out, params are explained)
Sentiment: This book explains C # This programming language, all from the compiler, the CLR's execution principle angle, very deep. These two chapters personally feel nothing particularly important, so list some important concepts and be familiar with these concepts.
"Clr.via.c# Third Edition" Part II 8th, Chapter 9 reading notes (iv)