Link to home
Create AccountLog in
Avatar of lefodnes
lefodnes

asked on

Checking if int contained inside an array of ints in c#

Hi
I use this code to check if an int is inside an array of an int:
int[] aI = { 6, 12, 20, 21 };
ph.Visible = aI.Contains(20)

Open in new window


How can I do this in one line, without specifying the array variable, just something like:
ph.Visible = (int[] {6, 12, 20, 21}).Contains(20);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of lefodnes
lefodnes

ASKER

Oh... I should have figured that out myself... Just missing one "new"...
Thanks, both!