[c#] How to check if a DateTime field is not null or empty?

I am very new in C# and I have a doubt.

In an application on which I am working I found something like it in the code:

if (!String.IsNullOrEmpty(u.nome))

This code simply check if the nome field of the u object is not an empty\null string.

Ok this is very clear for me, but what can I do to check it if a field is not a string but is DateTime object?

This question is related to c#

The answer is


DateTime is not standard nullable type. If you want assign null to DateTime type of variable, you have to use DateTime? type which supports null value.

If you only want test your variable to be set (e.g. variable holds other than default value), you can use keyword "default" like in following code:

if (dateTimeVariable == default(DateTime))
{
    //do work for dateTimeVariable == null situation
}