Is there a better .net way to check if a DateTime has occured \'today\' then the code below?
if ( newsStory.WhenAdded.Day == DateTime.Now.Day &&
FYI,
newsStory.Date == DateTime.Today
will return the same compare result as coding
newsStory == DateTime.Today
where newsStory
is a DateTime
object
.NET is smart enough to determine you want to compare based on Date only and uses that for the internal Compare. Not sure why, and actually having trouble finding documentation for this behaviour.