Reputation: 21
I have two integers called range1 and range 2 and I want to use them in an if statementas follows
if((range1 || range2)>20 && (range1 || range2)<=50)
Console.WriteLine("some Message");
I get an error saying I cannot us the || operator in an int && int comparison. I was trying to avoid coding for the larger of range1 or range 2 as the values can be either positive or negative. Any suggestions would be appreciated.
Thanks.
Om
Upvotes: 0
Views: 34
Reputation: 887195
||
doesn't work like that. It's a logical operator that can only operate on booleans.
Instead, you can write if (range1 > 20 || range2 > 20)
Upvotes: 2