Nullable type support in the community preview

One reader commented that nullable types don’t seem to fully work in the community preview drop.

He’s correct, and I apologize for not making that clearer in my post.

The time constraints of the community preview prevented us from getting all the nullable support in the compiler, but it will be there in the upcoming beta.

For the community preview, the following things work:

  • You can write a nullable type using the “?“ syntax

  • There are conversions from T to T?

  • You can use HasValue and Value on the type.

The following things don’t work:

  • Adding two nullable ints together (or any other operations that operate on the underlying type)

  • Comparing a nullable instance to the literal “null“

  • Using the ?? operator

  • Converting from S? to T? if a conversion from S to T exists.

Comments (5)

  1. Kyle Tinsley says:

    Is there a new "??" operator? And speaking of beta, can we still expect beta 1 to be released at TechEd Europe?

  2. damien morton says:

    Are we likely to see non-nullable types in 2005?. Seems to me that non-nullable types will solve more problems and bugs than nullable types will.

  3. Doug McClean says:

    Now that we have nullable types, can we get methods like (on the Int32 type):

    public static Int32? TryParse( /* same overloads as we have now for Parse */ )