What is that question (?) sign after a type declaration?

  • Thread starter ....DotNet4Ever....
  • Start date
D

....DotNet4Ever....

I have been noticing declarations like this:

private DateTime? _creationdate;

and have been wondering what is the function or meaning of that question
sign after the member type name. I searched the web but naturally with such
a thing in a query yields a lot of noise and no suitable results.

Can somebody enlighten me?

Cheers,
Emilio
 
P

Pavel Minaev

I have been noticing declarations like this:

    private DateTime? _creationdate;

and have been wondering what is the function or meaning of that question
sign after the member type name. I searched the web but naturally with such
a thing in a query yields a lot of noise and no suitable results.

Can somebody enlighten me?

"T?" is syntactic sugar for writing "System.Nullable<T>". You can look
up the details on the latter in MSDN, but briefly, it is a type that
wraps any other value type, and adds null to its domain of values. So,
in your example, _creationdate can be either a DateTime, or null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top