Set an empty DateTime variable

前端 未结 12 2081
走了就别回头了
走了就别回头了 2020-12-16 08:59

I would declare an empty String variable like this:

    string myString = string.Empty;

Is there an equivalent for a \'DateTime\' variable

12条回答
  •  心在旅途
    2020-12-16 09:45

    Since DateTime is a value type you cannot assign null to it, but exactly for these cases (absence of a value) Nullable was introduced - use a nullable DateTime instead:

    DateTime? myTime = null;
    

提交回复
热议问题