What is the second meaning of a single ampersand in C#?

A single & is "Bitwise AND operator", just like dove said. I'm looking at second part of question: "why it works?"

Think in binary:

 000 = 0
 001 = 1
 010 = 2
 011 = 3
 100 = 4
 101 = 5
 110 = 6
 111 = 7
 and so on

Note all even numbers ends with 0; so if last bit bitwise check against 1 returns zero (meaning "doesn't match"), its a even number;


Here:

The unary & operator returns the address of its operand (requires unsafe context).

Binary & operators are predefined for the integral types and bool. For integral types, & computes the logical bitwise AND of its operands. For bool operands, & computes the logical AND of its operands; that is, the result is true if and only if both its operands are true.

The & operator evaluates both operators regardless of the first one's value.

Tags:

C#

Linq