<p>This is probably pretty basic... but I don't seem to get it:</p>

<p>How does </p>

<pre><code>(2 &amp; 1) = 0
(3 &amp; 1) = 1
(4 &amp; 1) = 0
</code></pre>

<p>etc..</p>

<p>This pattern above seems to help find even numbers</p>

<p>or </p>

<pre><code>(0 | 1) = 1
(1 | 1) = 1
(2 | 1) = 3
(3 | 1) = 4
(4 | 1) = 5
(5 | 1) = 5
</code></pre>

<p>I know how boolean algebra works between bits. But I don't understand how Boolean algebra works with integers (in C# at the least).</p>

<p>thanks in advance.</p>

It works the same way in C# as it does in binary.
```
2 | 1 = 3
```
and
```
4 | 1 = 5
```
.
To understand this, you need to think about the binary representation of 1,2,3,4,and 5:
```
010 | 001 = 011
```
and
```
100 | 001 = 101
```
.
Similarly:
```
010 & 001 = 000
```
and
```
011 & 001 = 001
```