How do I make it so that something happens if condition a and condition b are true or condition c and condition d are true. I was thinking something like
if a = true && b = true || c = true && d = true
{
Console.Write("Hello")
}
but I am not sure.
Loading
VulpesPosted Nov 16, 2011, 1:53 PM
if ((a && b) || (c && d))
{
Console.Write("Hello");
}
Don't be afraid to use parentheses if (like me) you can't remember the operator precedence rules.
Also no need to do stuff like 'a == true' if 'a' is a boolean expression. Just do 'a'.
VulpesPosted Nov 16, 2011, 2:06 PM
If say a, b, c and d were ints and you wanted either a and b to be 1 or c and d to be 1, then you'd do this:
Jeremy StonePosted Nov 16, 2011, 1:59 PM