If-Else in C#
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? ;)
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
if("a"=="d")
{
//do something
}
else if("a"=="c")
{
// do something else
}
else
{
//do something if i am crazy
}
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28
Thanks, Tek. I fixed the problem. I was out of scope for what I wanted to do.
cscgal
The Queen of DaniWeb
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
All the C++ would be doing is converting 1 into "true"; that's not rocket science. This would work:
while(Convert.ToBoolean(1)) {}
Tekmaven
Software Architect
1,274 posts since Feb 2002
Reputation Points: 322
Solved Threads: 28