2
Answers

Or Logic within If statements

Jonathan Mercer

Jonathan Mercer

17y
1.5k
1
Hey All,

I have been using C# for awhile and I was wondering if there was a short cut when it comes to using the '||' in an if statment.  For example.  If I have an int i and I want my code to do the same thing if i = 4,6 or 7.  I know that I could use a swich statement and or I could use if(i = 4 || i=6 ....) .  What I want to do is: if(i= 4 || 6 || 7)  Is there a shortcut that would allow this.  I have been looking but I haven't been able to find any.

Thanks.
Answers (2)