Mega Code Archive

 
Categories / C# Tutorial / Operator
 

&& vs &

using System; class MainClass {     static bool Method1()     {         Console.WriteLine("Method1 called");         return false;     }     static bool Method2()     {         Console.WriteLine("Method2 called");         return true;     }     static void Main()     {         Console.WriteLine("regular AND:");         Console.WriteLine("result is {0}", Method1() & Method2());         Console.WriteLine("short-circuit AND:");         Console.WriteLine("result is {0}", Method1() && Method2());     } }