C# Comparing a String to an Array?

I have an Array of strings. What I have done Is set up a command prompt in unity. When I press enter I want my script to see if the entered text is the same as any in my string array, and if it is, execute the appropriate command.

For example; If I type “/home” I want to press enter and for my script to find “/home” in my array, and then I want it to execute the appropriate command. (Which is just changing the scene)

Thank you!

I would personally do it through a foreach loop, i.e.

public int GetScene (string[] array, string input)
{
    foreach (string s in array)
        if (input == s)
            return System.Array.IndexOf (array, s);

    return null;
}

This function takes an array and an input string, and returns the index of the input string in the array if there is a match.