DateTime.TryParse(p.birthday, out Dob)
successfully converts the string
to DateTime
, so it returns true. You invert this with !
, giving false.
When the execution gets to the &&
operator, it sees the first operand is already false
, so doesn't bother executing the second operand.
You could either execute both beforehand, or use the non-shortcut AND operator, &
.
Edit: Or
if (!(DateTime.TryParse(p.birthday, out Dob) || DateTime.TryParse(p.deathday, out Dod)))
{
...
}