- ASP.NET Core 2 High Performance(Second Edition)
- James Singleton
- 92字
- 2021-07-08 09:38:58
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;
推薦閱讀
- 深度實踐OpenStack:基于Python的OpenStack組件開發
- Design Principles for Process:driven Architectures Using Oracle BPM and SOA Suite 12c
- R語言經典實例(原書第2版)
- .NET 4.0面向對象編程漫談:基礎篇
- Raspberry Pi for Secret Agents(Third Edition)
- Instant Typeahead.js
- Python王者歸來
- 精通Python自然語言處理
- Scala編程實戰(原書第2版)
- 運用后端技術處理業務邏輯(藍橋杯軟件大賽培訓教材-Java方向)
- ASP.NET開發與應用教程
- C++ Fundamentals
- 零代碼實戰:企業級應用搭建與案例詳解
- Arduino機器人系統設計及開發
- HikariCP數據庫連接池實戰