In C#, what is the `?` in the type `DateTime?`

c#, nullable

Solution

The `?` makes it a nullable type (it's shorthand for the `Nullable<T>` Structure and is applicable to all value types).

Nullable Types (C#)

Note:

The `??` you linked to is the null coalescing operator which is completely different.

Problem

I just ran across some code while working with System.DirectoryServices.AccountManagement ``` public DateTime? LastLogon { get; } ``` What is the ? after the DateTime for. I found a reference for the ?? Operator (C# Reference), but it's not the same thing. (280Z28: Here is the correct link for Using Nullable Types.)

Original source

Related problems