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