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

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.

主站蜘蛛池模板: 镇江市| 绥芬河市| 米林县| 兰州市| 南康市| 泽普县| 衡水市| 罗田县| 黎平县| 鸡泽县| 乌拉特后旗| 克山县| 蓝田县| 白城市| 商河县| 宜宾县| 尖扎县| 潞城市| 临城县| 新巴尔虎左旗| 平度市| 金门县| 东阳市| 东方市| 濮阳市| 昌都县| 施甸县| 江门市| 太和县| 乌兰察布市| 周宁县| 海城市| 青龙| 正安县| 衡东县| 泗洪县| 肃北| 垫江县| 宁明县| 阿鲁科尔沁旗| 台南市|