It's a shorthand for writing Nullable<int>
or Nullable<DateTime>
. Nullables are used with value types that cannot be null (they always have a value).
It is not specific to C#4 by the way.
You can only assign an int?
to an int
if it has a value, so your code would have to do things like:
int? n = 1;
int i = n ?? default(int); //or whatever makes sense
Also note that a Nullable
has two properties, HasValue
and Value
that you can use test if a value has been set and to get the actual value.