O'Reilly logo

A Programmer's Guide to C# 5.0, 4th Edition by Nick Wienholt, Eric Gunnerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 27

image

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required