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

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;
主站蜘蛛池模板: 大姚县| 涿鹿县| 土默特左旗| 阜康市| 若尔盖县| 涞源县| 铜陵市| 常州市| 游戏| 晋城| 静海县| 涿鹿县| 民乐县| 华亭县| 高淳县| 郎溪县| 青州市| 西乌珠穆沁旗| 青阳县| 正宁县| 敦化市| 平和县| 莱州市| 富阳市| 芦溪县| 东乌珠穆沁旗| 临猗县| 冕宁县| 新民市| 石棉县| 铜川市| 怀柔区| 保康县| 股票| 鄱阳县| 民县| 海晏县| 罗甸县| 许昌县| 日土县| 台北市|