2
How to treat a field DateTime
that comes as "null"
(I know that DateTime
can’t be null
) of a legacy basis?
Consulting a WebService
it returns a field DateTime
as 01/01/0001
(no value) in the case of a string
empty or null there is an "elegant" way to treatIsNullOrEmpty
My question is: What is the best way to treat a DateTime
"null", ie with value 01/01/0001
You can Try Comparing it with
DateTime.MinValue.Date.ToString("d")
if think that is the Elegant?– Frank Fajardo
Appreciate your comment, I’ll Try it.
– rubStackOverflow
@rubStackOverflow I’m not sure I understand what you want. The answer already does what you want. Or isn’t that right? Do you want the factor to be null? Do you need this? Do you only need to do something different if you have this date? Is it certain that this date will always represent invalid data? If you give a larger context of how you are using, you may have a better solution.
– Maniero
Yes, the answer does what I want seen that
DateTime.MinValue
may be replaced by01/01/0001
. I didn’t want to have to compare the date with01/01/0001
(ex: minhaData ==01/01/0001
). I don’t want the date to be null, the null date always comes with01/01/0001
webservice.– rubStackOverflow