I have the following line of code:
CType(IIf(CBool(product.IsDiscontinued Is Nothing Or product.IsDiscontinued = True), False, True), Boolean?)
What does the Boolean?
mean at the end. I have seen it used on other data types as well.
I have the following line of code:
CType(IIf(CBool(product.IsDiscontinued Is Nothing Or product.IsDiscontinued = True), False, True), Boolean?)
What does the Boolean?
mean at the end. I have seen it used on other data types as well.
That's a Nullable(Of Boolean)
.
It allows value types to be Nothing
.
The ?
at the end is a shortcut for Nullable<T>
, in this case Nullable<Boolean>
.
Using Nullable allows you to store null inside of a value type that you wouldn't otherwise be able to.
Nullable... It's a nullable boolean...
As a quick aside, in the back end, these can create boxing/unboxing fun if you're not careful...
Here's a nice article explaining it (though it's written for c#)
http://msmvps.com/blogs/luisabreu/archive/2008/04/26/c-and-nullable-value-types.aspx