Why is null not allowed for DateTime in C#?

前端 未结 6 784
情书的邮戳
情书的邮戳 2021-01-01 08:42

Why it is not allowed to assign null to a DateTime in C#? How has this been implemented? And can this feature be used to make your own classes non-nullable?

Example:

6条回答
  •  忘掉有多难
    2021-01-01 09:38

    DateTime is a struct and not a class. Do a 'go to definition' or look at it in the object browser to see.

    HTH!

提交回复
热议问题