How to reverse boolean value

  • Thread starter Thread starter moondaddy
  • Start date Start date
M

moondaddy

I'm new to c# and want to know the preferred way to reverse a Boolean value.
for example:



in vb I can do this:



dim flag as Boolean



flag=not flag



Is there something similar in c# or do I need to use and if statement?



Thanks.
 
moondaddy said:
I'm new to c# and want to know the preferred way to reverse a Boolean
value. for example:

in vb I can do this:

dim flag as Boolean
flag=not flag

in C# (and other C like languges) ! means not
simply replace not with ! (and add a semicolon)

flag = !flag;

Hope this helps
Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top