MULTIPLE CONDITIONS IN IF STATEMENT OR SPLITTING USING C#

F Scott Fitzgerald

Total Post:29

Points:203
Posted by  F Scott Fitzgerald
C# 
C#
 1260  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. Babe Zaharias

    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();

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!