I wanted to have an optional date parameter for a method (defaulted to MinValue), in order to check if the user had actually supplied a value or not (supplying MinValue was invalid), but I'm not allowed as apparently it's not a compile-time constant.
According to the MSDN page, "The value of this constant is equivalent to 00:00:00.0000000, January 1, 0001."
So why is that not compile-time constant? And why is it different from passing in Int32.MinValue, which is allowed?
You cannot define a DateTime constant (or structs). From MSDN allowed types for const are:
One of the types: byte, char, short, int, long, float, double, decimal, bool, string, an enum type, or a reference type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With