Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question mark on a type

I've used this quite innocently for a while now without actually knowing much about it, but basically it's:

Private _SomeFieldDate As DateTime?

or...

Private _SomeFieldInt As Int32?

I realise that the question mark on the end allows the definition of a Null or rather Nothing value to be assigned to the field, but what exactly happens here, and what is the term for this question mark?

(PS: I did try looking for this on SO but couldn't find it; if this has previously been posted then would you mind popping a link to the post in an answer, please?)


1 Answers

It's called a nullable and the question mark is short for

Nullable<T>

More info on msdn

like image 194
Kristof Avatar answered Jan 28 '26 21:01

Kristof



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!