[C#] Some help with If statements (The condition)

Skilled Illusionist
Joined
Jul 1, 2007
Messages
367
Reaction score
1
Hello, I would like to know, is it possible (and if it is, how) to do the following:
Code:
if (Ini.IniReadFile("status", "first") != "yes" OR "no")
{
(statement)
}

Thanks to anyone who helps!
 
if (Ini.IniReadFile("status", "first") || !Ini.IniReadFile("status", "first"))

Think that should work, but I don't know C# very well...
 
I don't think that would work :smile:

I have found a solution!
Code:
             switch (Status)
            {
                case "yes":

                    break;
                 case "no":

                    break;
                default:
                    MessageBox.Show("Config file not found");
                    Application.Exit();
                    break;
            }
 
Ah that way.

Using switch takes longer, so better to use an if:

if (Ini.IniReadFile("status", "first") == "on" OR !Ini.IniReadFile("status", "first") == "off")
{
// yes or no
}
else
{
// oops
}
 
Im Learning C# And The Only Thing That Work And Isnt Very Long Like A Switch For This Is:
if (Ini.IniReadFile("status", "first") != "yes" ||Ini.IniReadFile("status", "first") != "no")
{
(statement)
}
 
If OR doesn't work, use || ^^
 
start reading what functions do and what they take as parameters...

i dont know **** about C# and still i know that IF is a conditional statement so a IF statement needs a condition...

i dont know **** about C# and still i know that a condition is something that trought diferent computations or actions evaluates to some sort of boolean value.

now that you know both of those things you can try and use a IF so first thing you need is a condition

Code:
Ini.IniReadFile("status", "first") != "yes" OR "no"

does this return something that can be used/considered a boolean?
is this even something that returns anything? (im finding rather odd the lack of paranthesis in the "yes" OR "no" part)

and tbh this doesn't make sense from the logical statement view...

Code:
((Ini.IniReadFile("status", "first") != "yes") OR (Ini.IniReadFile("status", "first") !="no"))

this would make more sense but anyways it could be the gramatic of C#.

Daevius said:
if (Ini.IniReadFile("status", "first") || !Ini.IniReadFile("status", "first"))

:P this would only work if u allways wanted a something to be true and it would allways be easier to do if(true).
 
Lol, indeed. I don't know anything about C# lol.

It depends on what Ini.IniReadFile("status", "first") returns, to what you test it in your IF query.
 
Back