In.. NET. The value type is stored in the memory stack and cannot be null. The reference type is stored in the Heap of the memory, it can be Null. The value types include common int, decimal, Datetime, etc. The general value types are inherited from struct, and the reference types are similar to string, ArrayList, and so on. What should we do if we want to set the value type to null.
In practical use, there are also cases where the value type is set to null, such as DateTime type. If it is obtained from the database, the database is null, how should I set it in my program? If it is set to the default initialization value, it certainly does not meet the requirements, so we 'd better set it to Null. How should we set it.
In C #, you can wrap the value type into a reference type using a very simple statement, that is, using question marks, as shown below:
Int? I = null;
At this time, we can find that the int type can also be set to null.