Joe Swindell
Joe Swindell

Reputation: 671

ASP.NET boolean variable

I've been looking at some source code for an ASP.NET page and stumbled across

booLockAll=(booLockAll==false);

I've never seen a variable declared like this in any other language.
Is this unique for ASP.NET?
Is this just wrong?

Why would you not write it: booLockAll==false

Upvotes: 0

Views: 1627

Answers (4)

SMI
SMI

Reputation: 311

That means if previous value of booLockAll was false then new value will be true or if previous one was true then new one will be false.

Upvotes: 0

timi2shoes
timi2shoes

Reputation: 95

The code is used to change the value of booLockAll.

Sample code that does the same

if(booLockAll==false)
{
   booLockAll = true;
}
else
{
   booLockAll = true;
}

Upvotes: 0

Fedor Hajdu
Fedor Hajdu

Reputation: 4695

That's just invert of a bool variable, just like

booLockAll = !booLockAll

Upvotes: 0

Ondrej Tucny
Ondrej Tucny

Reputation: 27974

This is not a declaration. It's an assignment statement whose effect is inverting the variable's value.

booLockAll is false => (booLockAll==false) yields true
booLockAll is true  => (booLockAll==false) yields false

Easier and a lot more readable would be to use booLockAll = !booLockAll;.

Upvotes: 3

Related Questions