C# Nullable<DateTime> to string

Viewed 31695

I have a DateTime? variable, sometimes the value is null, how can I return an empty string "" when the value is null or the DateTime value when not null?

11 Answers

According to Microsoft's documentation:

The text representation of the value of the current Nullable object if the HasValue property is true, or an empty string ("") if the HasValue property is false.

Related