What will be printed out as a result of the following code execution:
 
class Program
{ 
    static bool SomeMethod()
    { 
        Console.WriteLine("Method was invoked"); 
        return true;
     } 
     static void Main(string[] args) 
     {
          if (true & false & SomeMethod()) 
          { 
               Console.WriteLine("Inside IF operator"); 
           } 
       } 
  }
 
Explanation
& operation inside of an IF statement allows to fully evaluate a condition independently of its operands, even if it is obvious that the result does not depend on the subsequent operands. This operation differs from the && operation in that it evaluates the expression entirely.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes