What happens if the first part of an if-structure is false?

Posted by djerry on Stack Overflow See other posts from Stack Overflow or by djerry
Published on 2010-05-19T10:05:44Z Indexed on 2010/05/19 10:10 UTC
Read the original article Hit count: 175

Filed under:
|

Hey guys,

I was wondering what happens when a program processes an if-structure with multiple conditions. I have an idea, but i'm not sure about it. I'll give an example :

List<string> myTestList = null;
        if (myTestList != null && myTestList.Count > 0)
        {
            //process
        }

The list is null. When processing the if, will it go from left to right exiting the if as soon as one condition is false?

I've tried it and seems to throw no errors, so i assume the above explains it, but i'm not sure.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about if-condition