- 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;
推薦閱讀
- Learning Scala Programming
- Java逍遙游記
- Mastering AWS Lambda
- Spring Cloud Alibaba微服務架構設計與開發實戰
- WSO2 Developer’s Guide
- Java Web及其框架技術
- 用Flutter極速構建原生應用
- Bootstrap 4:Responsive Web Design
- 用戶體驗增長:數字化·智能化·綠色化
- 單片機C語言程序設計實訓100例
- PLC應用技術(三菱FX2N系列)
- RealSenseTM互動開發實戰
- Service Mesh實戰:基于Linkerd和Kubernetes的微服務實踐
- OpenCV with Python By Example
- Clean Code in C#