Vb.net – Is there such a thing as a nullable bool in vb.net

nullablevb.net

I am working through my new MVC book and of course, the samples are all in c# as usual.

There is a line of code that says

public bool? WillAttend { get; set; }

The author explains that the question mark indicates that this is a nullable (tri-state) bool that can be true, false. or null. (A new C# 3 convention.)

Does vb.net support any convention like this. Certainly I can declare a boolean in vb.net and I can explicitly set it to Null (Nothing in vb.net).

What's the difference. IS there more to it in c#. Advantages?

Best Answer

You can declare a nullable value 3 ways in VB:

Dim ridesBusToWork1? As Boolean
Dim ridesBusToWork2 As Boolean?
Dim ridesBusToWork3 As Nullable(Of Boolean)

Further Reading: MSDN - Nullable Value Types (Visual Basic).

Related Topic