Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sunny SharmaRank #223 · 11.1K reputationPosted Jun 23, 2013, 3:42 AM EDT
& is a bitwise operator where as && is a logical operator.
Bitwise operators can operate on both -Integer & Boolean arguments where as Logical operators can operate only on Boolean arguments.
Hope you got the point.
Mark it as answer if it helps.
Cheers!
VulpesRank #55 · 29.2K reputationPosted Jun 23, 2013, 6:51 AM EDT
1. In the case of the & operator, both operands are always evaluated.
2. In the case of the && operator, the second operand is only evaluated if the first operand evaluates to 'true'.
For this reason, && is known as a 'short-circuiting' operator because it avoids a potentially unnecessary step and is nearly always preferred in practice.
However, on rare occasions evaluating the second operand may have a side effect which will not take place if the first operand is false. This can occur if the second operand involves a method call or property access.
So, if you're relying on this side effect you should use & rather than && though such programming is generally regarded as poor practice in a high level language such as C#.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 23, 2013, 7:18 PM EDT
hi,
&& is also called "short-circuiting" logical operators.
&& is used to perform AND operation.it is generally used with IF condition. In this case of &&, if the first operand condition is false, then it doesn't bother evaluating the second operand condition.
& is called bitwise logical operation. in this case both Conditions are always execute.
hope this will help you.