About This eBook by Bart De Smet

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

O'Reilly logo

Nullability and Lifted Operators

Introduced in .NET 2.0, nullability allows for the use of struct values in conjunction with a null value. As a short recap, the ? suffix can be appended to a value type name to create the nullable variant of it. This enables you to write code like this:

int? a = 42;if (a != null)  // Really checks for a.HasValue    Console.WriteLine("Value = " + a /* or explicitly write a.Value */);int? b = null;if (b == null)    Console.WriteLine("Null");

As with most changes that touch the type system of the runtime (and hence languages taking advantage of its features), nullability had quite an impact on the language. In the context of operators, the concept of lifted operators was introduced. ...

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