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

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.

主站蜘蛛池模板: 历史| 醴陵市| 靖西县| 盐津县| 长沙市| 和林格尔县| 夏邑县| 保定市| 营山县| 浦县| 建阳市| 师宗县| 新平| 郯城县| 通榆县| 渭源县| 夏津县| 金塔县| 常州市| 墨竹工卡县| 慈溪市| 始兴县| 太白县| 兴城市| 浦城县| 天柱县| 衡水市| 平乐县| 正安县| 玛沁县| 和静县| 东宁县| 桦甸市| 张家港市| 苍南县| 兰州市| 贵德县| 得荣县| 新乡县| 分宜县| 南城县|