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

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;
主站蜘蛛池模板: 伊宁县| 卢湾区| 平江县| 乐清市| 京山县| 济源市| 通许县| 新邵县| 余江县| 宝清县| 聂荣县| 阳江市| 泗洪县| 彩票| 林芝县| 临安市| 德保县| 永州市| 成武县| 改则县| 迁安市| 广昌县| 临桂县| 日土县| 车致| 宁国市| 黔西县| 仪陇县| 仁布县| 龙江县| 九江县| 万州区| 高阳县| 福建省| 于都县| 望江县| 上饶县| 桐庐县| 霍林郭勒市| 洪泽县| 巴里|