Hi Dave,

"Dave" wrote:

got my answer, Thanks

in C# if you type & it is bit AND operator, it returs int, that is the

reason why the compiler generated error.

In order to get boolean AND comparison you have to write &&

if(checkLogin && 1)

{ }

--

Vadym Stetsyak aka Vadmyst

&& is the logical and, and for x being a bool value, the expression

x && true

equals

x

The expression

x && 1

with x being an int is an invalid expression because operator && takes two

bools as its operands.

I've read VB.NET code once, and what they did with the logical operators and

bit-wise operators is just plain ugly and counter-intuative. I've never been

a VB fan though.

Anyway,

operator &: bit-wise AND

operator &&: logical AND

operator |: bit-wise OR

operator ||: logical OR

The bit-wise operators can take any integer value type (short, int, long

....), while the logical operators take bool as operands.

For instance:

15 & 4 yields 4

true && false yields false

11 | 4 yields 15

true || false yields true

Note however that the logical operators && and || are short-circuiting. An

explanation:

For the logical && operator. If in the expression

x && y

statement x yields false, then statement y is not executed since "false &&

y" yields false. For instance in the expression

f( ) && g( )

if method f returns false, method g is not executed and the result of the

expression is false.

For the logical || operator. If in the expression

x || y

statement x yields true, then statement y is not executed since "true || y"

yields true. For instance in the expression

f( ) || g( )

if method f returns true, method g is not executed and the result of the

expression is true.

Kind regards,

--

Tom Tempelaere.