(P6) the String. Format method uses StringBuilder internally to Format the String;
(P8)
System. Convert also supports converting any custom type to any primitive type, as long as the custom type inherits the IConvertible interface;
System. BitConverter provides the conversion method between the primitive type and the byte array;
(P11)
If all types are traced back to a common base class, the transformation based on this base class (that is, the transformation from the base class to the subclass itself) should use as; the transformation between the subclass and the subclass, the conversion operator should be provided for forced transformation;
The transformation operator is actually a method, and the type conversion needs to be completed by manually writing code;
(P12) there is a problem with the as operator, that is, it cannot operate on primitive types. If an algorithm involving the primitive type is involved, it must be determined by the type before transformation to avoid transformation failure;
(P13) Exceptions may cause performance loss;
(P15) syntax T? Is short for Nullable <T>. The two can be converted to each other;
(P16)
?? The greatest use is to assign null type values to the corresponding primitive type for simplification;
The essential differences between const and readonly are as follows:
Const is a constant during the compilation period, and readonly is a runtime constant;
Const can only modify the primitive type, enumeration type, or string type. readonly has no restrictions;
(P20) One of the reasons for creating enumeration is to replace the actual value;
(P22) CLR supports using the operator keyword to define static member functions in the type to overload operators;
(P25) we recommend that you do not use all non-generic collection classes as much as possible after generics are created;
(P28) in FCL, the string comparison is overloaded to compare the "type value", rather than the comparison of the "reference itself;
(P29)
For reference types, to define "equality of values", you should only reload the Equals method and make "=" to indicate "reference equality ";
The operators "=" and "Equals" can be overloaded to indicate "Value Equality" and "reference equality" in terms of syntax implementation ". Therefore, in order to clarify that there is a method that must be compared with "reference equality", FCL provides the Object. ReferenceEquals method. This method compares the two examples to see if they are the same.
(P31) The GetHashCode method should generate HashCode based on those read-only attributes or features;
(P32) The ToString method of the Object will return the type name of the current type;
(SpO2) in the shortest copy process, the string should be considered as a value type;
(P42) always use dynamic to simplify reflection implementation;
(P44) arrays should not be used when the number of elements is variable;
(P49) foreach is used to traverse a set element that inherits the IEmuerable or IEmuerable <T> interface;
(P55)
Use a pair of parentheses to enclose the actual types;
The non-Generic set is in the System. Collections namespace, and the corresponding Generic set is in the System. Collections. Generic namespace;
(P73) Any LINQ query can be replaced by calling the extension method;
(P74) a Lambda expression is a simple delegate. The operator "=>" indicates the parameter of the method on the left and the method body on the right;
(P97) delegation is also a type, which is no different from any reference type in FCL;
(P98) the left side of the Lambda expression operator "=>" is the method parameter, and the right side is the method body, which is essentially an anonymous method;
(P103) The delegate is a method pointer; the delegate is a class. when instantiating it, the referenced method should be used as the parameter of its constructor;
(P118) if the type needs to be explicitly released, you must inherit the IDispose interface;
(P135) to prevent events from being serialized, use the improved feature syntax [field: NonSerialized];
(P160) directly throw exception rather than throw will reset the stack information;
(P179) asynchronous mode greatly saves CPU resources by means of thread pools;
(P180) Locking uses the keyword lock and type Monitor. There is no substantial difference between the two. The former is actually the syntactic sugar of the latter;
(P181) EventWaitHandle and Semaphore provide thread synchronization functions in a single application domain. Mutex provides the ability to block and remove blocked threads across application domains;
(P187) the type of static methods should ensure thread security, non-static methods do not need to implement thread security;
(P189) the Thread created with Thread is the foreground Thread by default, that is, the IsBackground attribute is false by default;
(P223) the lock actually turns multithreading into a single thread (because only one thread is allowed to access resources at the same time );
(P226)
Abstract classes can have constructor methods. Even if no constructor is specified for abstract classes, the compiler will generate a default protected constructor for us;
The constructor of the abstract class should not be public or internal;
Abstract classes are designed to inherit only child classes, rather than generating instance objects;
The abstract class only needs to be visible to the subclass;
(P228)
Type attributes should be initialized before the constructor call is completed;
If the field does not set an initial value in the initiator, it should be initialized in the constructor;
(P229)
The initialization tool is the syntactic sugar of the compiler. After compilation, it is executed at the beginning of the constructor;
It can be understood as part of the constructor;
(P229)
If the method in the subclass contains the new Keyword, the method is defined as a method independent of the base class;
If the method in the subclass contains the override keyword, The subclass object calls this method instead of the base class method;
(P231)
The method of the Child class override parent class. Even if the child class is transformed to the parent class, the Child class method is called;
The subclass has a new parent class method, so the subclass method and the base class method are completely irrelevant. As long as the subclass is transformed into a parent class, the parent class method is called for the subclass;
(P239) the static method is consistent with the instance method in terms of loading time and memory usage;
(P241)
The extension method must be in a static class and cannot be a nested class;
The extension method must be static;
The first parameter of the extension method must be the type to be extended, and the this keyword must be added;
Extended attributes and events are not supported;
(P245) the abstract class solves "Is a" and the interface solves "Can do ";
(P253) The Singleton type should be sealed at the same time;
(P255) Static constructor should be used to initialize static reference types. However, if a static class only has a value type variable, you can relax this restriction;
(P257) If a nested class must appear, implement it as private;
(P301) as long as it is generic, it should be named with T as the prefix;
(P311)
The modifier of type members is private by default;
The default modifier of the class or interface is internal;
(P339) the architecture model aims to make unit tests more convenient;