CHAPTER 27
Nullable Types
It is sometimes useful to know whether a value has been defined. This concept is present for reference types (classes) by using the null value. Nullable types are used to support this concept with value types (structs).
A Simple Example
Assume you are writing a customer-tracking system and have created the following class:
class Customer{ public Customer(string name, string company) { Name = name; Company = company; } public string Name { get; set; } public string Company { get; set; } public string City { get; set; } public int YearOfBirth { get; set; }}
In addition to the name and company ...
Get A Programmer's Guide to C# 5.0, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.