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

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;
主站蜘蛛池模板: 格尔木市| 迭部县| 玉屏| 叶城县| 石泉县| 板桥市| 景东| 大化| 策勒县| 临城县| 宣化县| 兴安盟| 泰宁县| 静安区| 新余市| 新巴尔虎右旗| 平利县| 象州县| 蓝山县| 长治县| 江孜县| 东港市| 景泰县| 安乡县| 辽宁省| 汉阴县| 苏州市| 斗六市| 道孚县| 稷山县| 荆州市| 琼中| 伊金霍洛旗| 灵川县| 彭水| 新余市| 北碚区| 彰化县| 凤庆县| 成武县| 永泰县|