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

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;
主站蜘蛛池模板: 甘孜县| 全椒县| 普兰县| 全州县| 拜城县| 彩票| 康乐县| 秦安县| 大关县| 增城市| 宣威市| 苗栗县| 汽车| 武安市| 贡山| 潼南县| 古浪县| 石狮市| 潞城市| 柘城县| 呼伦贝尔市| 阜平县| 色达县| 永春县| 墨脱县| 靖宇县| 阿勒泰市| 永州市| 吴堡县| 九江县| 乐至县| 张家界市| 云龙县| 广河县| 宽甸| 疏附县| 永和县| 延寿县| 新郑市| 大余县| 平果县|