. NET notes (2),. net notes
Null merge Operator
?? The operator is called the null merge operator. If the left operand of this operator is not null, this operator returns the left operand; otherwise, the right operand is returned.
An error occurs when Average is used.
Because the data contains DBNull, it should be written
Decimal? AvgUPri = dt. AsEnumerable (). Average (q => q. Field <decimal?> ("Unit price "));
Ref, out
The out parameter is relatively simple. After the parameter is added, you do not need to declare the variable first.
Assertions
Do not place function calls in Debug. Assert statements. Use temporary variables
List
ArrayList // storage object, which requires packing when storing value-type data, which consumes a lot. An ArrayList can store different data types.
Generic
Advantages: algorithm reuse, type security, no binning compared to objects, and performance loss of Packing
Coordination and resistance to changes
Inverter:
Covariant:
Synchronous and asynchronous
Synchronous and asynchronous communication focuses on the message communication mechanism.
Synchronization: The caller takes the initiative to wait for the call results
Blocking non-blocking
Blocking and non-blocking focus on the status when the program is waiting for the call result (message, return value ).
Blocking: before the call result is returned, the caller suspends
Thread
Thread security considerations during foreach Loop
During foreach, do not try to remove or add the traversal set.
Any set, even if marked as thread-safe, will cause exceptions when adding or removing items during foreach.
Linq
from [type] id in source[join [type] id in source on expr equals expr [into subGroup]][from [type] id in source | let id = expr | where condition][orderby ordering,ordering,ordering...]select expr | group expr by key[into id query]