- Hands-On Object:Oriented Programming with C#
- Raihan Taher
- 114字
- 2021-07-02 12:44:34
Nullable types
The primitive types or value types are not nullable in C#. Consequently, there is always a requirement for the developer to make the type nullable, as a developer might need to identify whether the value is provided explicitly or not. The newest version of .NET provides nullable types:
Nullable<int> a = null;
int? b = a; //same as above
Both lines in the preceding example define the nullable variable, while the second line is just a shortcut of the first declaration. When the value is null, the HasValue property will return false. This will ensure that you can detect whether the variable is explicitly specified as a value or not.
推薦閱讀
- 程序設計與實踐(VB.NET)
- Learning Neo4j 3.x(Second Edition)
- JSP開發案例教程
- Functional Kotlin
- 常用工具軟件立體化教程(微課版)
- INSTANT Adobe Edge Inspect Starter
- 代替VBA!用Python輕松實現Excel編程
- R語言:邁向大數據之路(加強版)
- Getting Started with Python
- WordPress Search Engine Optimization(Second Edition)
- Android 5從入門到精通
- 分布式系統架構與開發:技術原理與面試題解析
- 微信公眾平臺開發最佳實踐
- WCF編程(第2版)
- Game Development Patterns and Best Practices