Or Logic within If statements

Jun 20 2007 10:12 AM
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)