0

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

1
  • Can you give us a little more context, is this in the code behind file? Where is booLockAll defined (there's no bool or var there) Commented Feb 27, 2014 at 15:24

4 Answers 4

3

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;.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, I've just never seen it written like this.
0

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

booLockAll = !booLockAll

Comments

0

The code is used to change the value of booLockAll.

Sample code that does the same

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.