user489041
user489041

Reputation: 28294

What does ?DataType mean in Vb.NET

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.

Upvotes: 1

Views: 506

Answers (3)

Rikon
Rikon

Reputation: 2696

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

Upvotes: 2

Justin Niessner
Justin Niessner

Reputation: 245419

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.

Upvotes: 5

SLaks
SLaks

Reputation: 887405

That's a Nullable(Of Boolean).

It allows value types to be Nothing.

Upvotes: 5

Related Questions