- 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;
推薦閱讀
- Spring Boot開發與測試實戰
- Leap Motion Development Essentials
- Windows Server 2012 Unified Remote Access Planning and Deployment
- Visual C++數字圖像處理技術詳解
- 微信小程序入門指南
- Visual C++開發入行真功夫
- Android傳感器開發與智能設備案例實戰
- 深度探索Go語言:對象模型與runtime的原理特性及應用
- 奔跑吧 Linux內核
- Arduino機器人系統設計及開發
- Hacking Android
- WCF技術剖析(卷1)
- Mastering ASP.NET Core 2.0
- Test-Driven iOS Development with Swift
- 從零開始學UI設計·基礎篇