How to check if it is zero datetime in c#? What I mean zero datetime is: 01.01.0001 00:00:00
4 Answers
You'll want to check against DateTime.MinValue
You should check against default(DateTime)
The value of that is the same as DateTime.MinValue but formally default(T) is better. It is more readable and more in line with default(int) , which is 0 and very different from int.MinValue.
In a generic class, default(T) works for DateTime as it does for all built-in value types.
you can use DateTime.MinValue
value of this constant is equivalent to 00:00:00.0000000, January 1, 0001.
Sounds like you want something like this:
if (myDateTime == DateTime.MinValue) { // Do stuff }