mercredi 11 juillet 2018

Why IF statement iterate over all AND conditions even if the first is false

In c# i've an IF condition like this

if(x != null && x.myprop != "value")
{
//
}

when x is null why the compiler continues after '&&' operator even if the condition is guarantee to be not satsfied.

i've null exceptions if i do x.myprop when x is null, i know that '?' fix the problem but i can't understand why it continues. Sorry for my bad english.

Aucun commentaire:

Enregistrer un commentaire