O'Reilly logo

C# 5.0 Unleashed 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

Use in C#

Let’s take a look at an example:

int a = 42;int b = null; // doesn't compileNullable<int> c = 42;Nullable<int> d = null; // this is valid

Having to write Nullable<int> every time you need a nullable integer can be quite tedious. For that reason, C# has created a shorthand syntax for nullables, suffixing the (value) type name with a question mark:

int? c = 42;int? d = null; // this is valid

Note: Kleene Closures

Readers who are familiar with regular expressions or formal means to express grammar and such might have heard about the Kleene closure operators. And even if you haven’t, you’ll have used wildcards in some command prompt environment. Three essential suffix operators exist, denoting different multiplicities. ...

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