C# bitwise AND operator '&' logic
<p>I'm finding difficult to understand how the ´&amp;´ operator works in relation to this code:</p>

<pre><code>for(int cnt = 0; cnt &lt; (1 &lt;&lt; somelist.Count()); ++cnt)
{
    for (int i = 0; i &lt; somelist.Count(); ++i)
    {
        //  1 &lt;&lt; 0 -- 1 -&gt; 1
        //  1 &lt;&lt; 1 -- 10 -&gt; 2
        //  1 &lt;&lt; 2 -- 100 -&gt; 4
        //  1 &lt;&lt; 3 -- 1000 -&gt; 8
        //  1 &lt;&lt; 4 -- 10000 -&gt; 16
        //  1 &lt;&lt; 5 -- 100000 -&gt; 32

        var l = (1 &lt;&lt; i);
        if ((cnt &amp; l) == 0)
        {
            // when is it getting here?
            // some code to execute
        }

    }
}
</code></pre>

<p>which ones are the cases when it enters the if condition and those where it doesn't? and why?</p>

<p>I already used the debugger on it, it is the logic behind that it's not clear. What it does is:</p>

<pre><code>e.g.

var cnt = 0
var l = 1
if ((cnt &amp; l)==0){ // true }

var cnt = 1
var l = 1
if ((cnt &amp; l)==0){ // false }

var cnt = 1
var l = 2
if ((cnt &amp; l)==0){ // true }

var cnt = 1
var l = 4
if ((cnt &amp; l)==0){ // true }

var cnt = 3
var l = 2
if ((cnt &amp; l)==0){ // false }

var cnt = 3
var l = 4
if ((cnt &amp; l)==0){ // true }
</code></pre>