Multiple Conditions in If Statement or Splitting using C#

Total Post:28

Points:196
C# 
C#
 1580  View(s)
Ratings:
Rate this:

when i am using if statements with multiple conditions, how are they managed in the compiler?

A) Will it ignore the second Statement, if the first statement is not fulfilled or vice versa?

If(time > 3.0 && hitEnabled)

B) Late Defintions are often recommended, so should i prefere to use one condition in if statements?

if(time > 3.0)

    if(hitEnabled)

Thanks!

  1. Post:19

    Points:133
    Re: Multiple Conditions in If Statement or Splitting using C#

    String someString = null;
    

            if (someString != null && someString[4].Equals('a'))
            {
                //// not called
            }

            if (someString != null || someString[4].Equals('a'))
            {
                //// exception
            }

            Console.ReadLine();

      Modified On Apr-03-2018 04:49:17 AM

Answer