jeudi 25 juin 2015

If statement logic - read left to right?

I have an if statement in vb.net that reads something like this:

If String.IsNullOrEmpty(someDate) Or CDate(someDate) > DateTime.Now Then
    'Do stuff here
End If

When someDate = Nothing, the app barfs. I could have sworn that these statements read left to right and as soon as it found a matching condition it would enter into the If code block.

I can write another statement that just does a null check. This results in no errors. Could someone clarify this?

Aucun commentaire:

Enregistrer un commentaire