how do I check if a string is inside of an array

I got a string array, i do not want to have a switch statement checking each individual variable in the array and comparing it to the sting. i tried to use

if (arrayVar.Contains(individualString)){
    // do something

but i am getting some errors. if some one has any ideas or better options to do this pls let me know. thanks in advanced

You have to loop through the array and check each entry.

foreach(string str in array)

If your question is whether or not there’s a better way to do this, you could also check out the Linq library which provides some handy functions for sorting and working with arrays.

Edit: After writing this I got a little curious as to faster/more readable solutions. This SO question has a lot of good options: