- 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;
推薦閱讀
- Kubernetes實戰(zhàn)
- 前端跨界開發(fā)指南:JavaScript工具庫原理解析與實戰(zhàn)
- Java入門很輕松(微課超值版)
- DevOps入門與實踐
- Data Analysis with IBM SPSS Statistics
- 可解釋機器學(xué)習(xí):模型、方法與實踐
- Extending Puppet(Second Edition)
- 從零開始學(xué)C#
- Visual Studio Code 權(quán)威指南
- JBoss:Developer's Guide
- PrimeFaces Blueprints
- 從零開始:C語言快速入門教程
- Visual C++程序設(shè)計與項目實踐
- C/C++代碼調(diào)試的藝術(shù)(第2版)
- The Applied Data Science Workshop