473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How to reverse boolean value

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.
--
mo*******@noemail.noemail
Feb 2 '07 #1
4 19701

bool b = false;

b = !b;

exclamation mark
"moondaddy" <mo*******@noemail.noemailwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...
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.
--
mo*******@noemail.noemail


Feb 2 '07 #2
"moondaddy" <mo*******@noemail.noemailwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...
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
Feb 2 '07 #3
Thanks to both of you. That's exactly what i was looking for.

"Bill Butler" <qw****@asdf.comwrote in message
news:gLNwh.322$h75.252@trnddc01...
"moondaddy" <mo*******@noemail.noemailwrote in message
news:Ov**************@TK2MSFTNGP02.phx.gbl...
>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

Feb 3 '07 #4
flag!=flag;

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

moondaddy wrote:
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.

Feb 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WindAndWaves | last post by:
Hi Gurus What is the best way to store a boolean value in a MySql table (e.g. true or false) AND ( ;-) am I asking this in the right newsgroup (I could not find one for MySQL) Thank you -...
4
by: Grzegorz Dostatni | last post by:
Good morning. I've got a Tkinter problem: File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 2310, in selection_present return self.tk.getboolean( TclError: expected boolean value but got "" ...
4
by: Simon Jefferies | last post by:
Hello, I've created an XSD file with the following in it: <xs:attribute name="Enabled" form="unqualified" type="xs:boolean" /> I am trying to set the XML to match this format, but how/what...
2
by: Douglas Buchanan | last post by:
This is a mystery! Why does the boolean value of a record change without my input. What follows describes the situation and the behavior. Table1: Field1: Text Field2: Yes/No Form1 has two...
3
by: Daves | last post by:
trying to get a boolean value from DataReader (that is, result from a SQL query); boolean MyBool = MyDataReader.GetBoolean(3); well it works using that number 3 but of course I would like to...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
2
by: Brian Henry | last post by:
say i have a dataset called dv and i have a boolean value i want to filter by "b_DoesWork" while the column name in the data view that i want to filter on is called "Works" how would i filter...
1
by: STAGED | last post by:
The script: proc bugsy { } { global helmet pack forget .widget1 if { $helmet(key1) } { pack .widget2 -anchor nw -side top -expand 0 } else { show_new_widget }
5
by: shana07 | last post by:
Good day all! I have one more question and needed some inputs from you guys. This is regarding condition value (T/F). My program (Driver) prints out condition values in reversed way - which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.