| | |
If-Else in C#
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
This might sound silly. But I'm working on a C# assignment for school right now, and I can't get a simple if-else statement to work. Isn't the syntax the same as in C++ or Java?
I want to do one thing if a boolean variable is true, something else if it's not. The "bool" type exists in C#, right?
I want to do one thing if a boolean variable is true, something else if it's not. The "bool" type exists in C#, right?
Dani the Computer Science Gal 
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
C# Syntax (Toggle Plain Text)
if("a"=="d") { //do something } else if("a"=="c") { // do something else } else { //do something if i am crazy }
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Thanks, Tek. I fixed the problem. I was out of scope for what I wanted to do.
Dani the Computer Science Gal 
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
•
•
Join Date: Mar 2004
Posts: 11
Reputation:
Solved Threads: 1
C# has the bool data type, which allows for true and false. Also another great resource for C# that I really like is http://www.codeproject.com (also has other sections besides C# too)
All the C++ would be doing is converting 1 into "true"; that's not rocket science. This would work:
while(Convert.ToBoolean(1)) {}
while(Convert.ToBoolean(1)) {}
-Ryan Hoffman
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
![]() |
Other Threads in the C# Forum
- Previous Thread: Enabling Step Into (#c)
- Next Thread: ADO.Net SQL UPDATE using OleDBAdapter
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# cast check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files forloop form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mailmerge mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox robot saving serialization server sleep socket sockets sql sql-server statistics stream string stringformatting sun table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






