- Home /
C Sharp int equal 1 or <4 && >15
How do I do an if statement that says basically:
if (i == 4 or i<4&&i>15)
when i is an int?
Answer by AchillesWF · May 14, 2012 at 01:55 AM
if ( (i == 4) || ((i<4) && (i>15)) )
But...how can i be less than 4 AND > 15, ever?
I have my >s in reverse as usual. Probably would have caused my next error. But this worked thank you.
How can you have your comparison signs reversed? The sign is pretty obvious ;) Both, the greater than and the lower than sign have a big end and a small end which matches exactly the "greater" and the "lower" number. If the big side is greater than the small side the expression is true.
big > small
examples:
10 > 4 is true
1 < 3 is true
1 > 3 is false
5 > 5 is false
6 > 5 is true
I can't understand how people can mess this up.
$$anonymous$$y primary school maths $$anonymous$$cher described it like pac-man- it goes for the bigger thing!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Error when checking if float is a whole number 2 Answers
if function broken? 3 Answers