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

Null conditional

The null conditional operator is a way of simplifying null checks. You can now place an inline check for null rather than use an if statement or ternary operator. This makes it easier to use in more places and will hopefully help you avoid the dreaded null reference exception.

You can avoid doing a manual null check, as in the following code:

int? length = (null == bytes) ? null : (int?)bytes.Length;

This can now be simplified to the following statement by adding a question mark:

int? length = bytes?.Length;
主站蜘蛛池模板: 甘泉县| 寻甸| 恩平市| 娱乐| 名山县| 宜宾县| 隆安县| 兴和县| 宜兰市| 湘乡市| 秦皇岛市| 广安市| 石林| 调兵山市| 水城县| SHOW| 永平县| 佛教| 南宁市| 四川省| 伊吾县| 海门市| 绥宁县| 苏尼特左旗| 博乐市| 安泽县| 平湖市| 罗源县| 泌阳县| 洪雅县| 成武县| 陇南市| 马边| 贵德县| 腾冲县| 西平县| 林甸县| 台中县| 长顺县| 扬州市| 临泽县|