Home / Software / Tips and Tricks / What are the diffrence between AND operators in c#?

What are the diffrence between AND operators in c#?

Updated:  10/26/2012 07:10 AM
Author:  Shiju Mathews

Status:    Resolved.


In C# and .Net two kind of "AND" operators are using "&" and "&&". They are diffrent in operation.


a&b is called a bitwise and b

& evaluates both of its operands and returns the logical conjunction ("AND") of their results. If the operands are integral, the logical conjunction is performed bitwise.


a&&b  is called 'a and b'

&& operates on boolean operands only. It evaluates its first operand. If the result is false, it returns false. Otherwise, it evaluates and returns the results of the second operand. Note that, if evaluating the second operand would hypothetically have no side effects, the results are identical to the logical conjunction performed by the & operator.