官术网_书友最值得收藏!

Nullable types

The primitive types or value types are not nullable in C#. Consequently, there is always a requirement for the developer to make the type nullable, as a developer might need to identify whether the value is provided explicitly or not. The newest version of .NET provides nullable types:

Nullable<int> a = null;
int? b = a; //same as above

Both lines in the preceding example define the nullable variable, while the second line is just a shortcut of the first declaration. When the value is null, the HasValue property will return false. This will ensure that you can detect whether the variable is explicitly specified as a value or not.

主站蜘蛛池模板: 鄢陵县| 金门县| 阿城市| 宁陕县| 伊春市| 弋阳县| 泰州市| 伊宁市| 江山市| 通州市| 湘西| 罗平县| 永修县| 仁怀市| 招远市| 莱阳市| 双桥区| 交城县| 青岛市| 金昌市| 新沂市| 内乡县| 元阳县| 江川县| 合江县| 琼海市| 金昌市| 清镇市| 和顺县| 海盐县| 龙南县| 江都市| 文成县| 汕头市| 安阳市| 平原县| 商水县| 遂昌县| 汉沽区| 江华| 永兴县|