&& vs & : Shortcut Operator « Operator « C# / CSharp Tutorial






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








3.5.Shortcut Operator
3.5.1.the shortcut operators: +=, *=, /=
3.5.2.&& vs &