Convert string to boolean
-
Hi i was wondering if someone could help me with converting a string to a boolean so i can do an if statement. what i'm wanting to do is like:
if (textbox4.text = "true")
{
}but it gives me an error :-\ thanks for you help in advance! Don't be overcome by evil, but overcome evil with good
-
Hi i was wondering if someone could help me with converting a string to a boolean so i can do an if statement. what i'm wanting to do is like:
if (textbox4.text = "true")
{
}but it gives me an error :-\ thanks for you help in advance! Don't be overcome by evil, but overcome evil with good
-
Hi i was wondering if someone could help me with converting a string to a boolean so i can do an if statement. what i'm wanting to do is like:
if (textbox4.text = "true")
{
}but it gives me an error :-\ thanks for you help in advance! Don't be overcome by evil, but overcome evil with good
Single = is assignment Double == is equality
if (textbox4.text == "true")
Boolean.Parse() to convert string to bool if needed Sean just beat me to it by seconds! :laugh: -- modified at 21:26 Thursday 27th April, 2006
-
Single = is assignment Double == is equality
if (textbox4.text == "true")
Boolean.Parse() to convert string to bool if needed Sean just beat me to it by seconds! :laugh: -- modified at 21:26 Thursday 27th April, 2006
-
You need to have two = signs if you are comparing:
if(textBox4.Text == "true") { // do stuff... }
You can use
bool.Parse()
if you need to convert a string to a boolean:bool myBool = bool.Parse("true");
Sean :)
Thanks alot guys to the both of you. [way off topic] Sean i tried to find a way to send you a PM or Email to thank you personally for helping me yesterday. The way you showed me with the listview worked. I just had a problem with the button! But when you was talking about the "Item properties" i was thinking as i was reading that "how in the heck does he remember all theese properties and such". Then it just dawned on me! listview1.items is the exact same thing as going to the properties manager for that control and changing it their. Your just doing the exact same thing but w/o the point n click!. It opened my eyes up to what was actually going on in the code! I was so happy after finding that out i drove home as fast as i could to try to send you a pm telling you thanks but there wasn't a way to do so. but anyways man thanks alot for the help i really appreciate it! Don't be overcome by evil, but overcome evil with good
-
Thanks alot guys to the both of you. [way off topic] Sean i tried to find a way to send you a PM or Email to thank you personally for helping me yesterday. The way you showed me with the listview worked. I just had a problem with the button! But when you was talking about the "Item properties" i was thinking as i was reading that "how in the heck does he remember all theese properties and such". Then it just dawned on me! listview1.items is the exact same thing as going to the properties manager for that control and changing it their. Your just doing the exact same thing but w/o the point n click!. It opened my eyes up to what was actually going on in the code! I was so happy after finding that out i drove home as fast as i could to try to send you a pm telling you thanks but there wasn't a way to do so. but anyways man thanks alot for the help i really appreciate it! Don't be overcome by evil, but overcome evil with good
-
Hi i was wondering if someone could help me with converting a string to a boolean so i can do an if statement. what i'm wanting to do is like:
if (textbox4.text = "true")
{
}but it gives me an error :-\ thanks for you help in advance! Don't be overcome by evil, but overcome evil with good
A good coding practice is to set your constant on the left side of your operator, so the compiler catches mistakes. For example:
if ( "true" == textbox4.text ) { }
will assure that you never are doing an assignment if you forget an = when you are intending to do a comparison. It's a good habit to get into.