C# If string is equal to any in array

Hi,
I’m no expert in using arrays, but I’m trying to find a way of checking if any string is in an array.
For example if I have:

public class pathFollow : MonoBehaviour {

string[] levels;
    
    void Start() {
         levels [0] = "1";
         levels [1] = "5";
    }
}

how do I check if the array ‘levels’ contains any of the strings I added in the start Void.

Thanks :slight_smile:

you can make it a lot easier for yourself by using a List instead of an array, then it’s just listName.Contains(stringToCheck) which is true/false depending on the result.

How to use my string as any string in a string array. According to condition the string would change to any of a string present in array. I want like this

public string[] usingsentence;
void Update()
    {
        foreach (string Subject in usingsentence)
        {
            string usingSubject;
            usingSubject = Logicsx.Instance.words[1].Words[0];
            //Here I want it to change the string[usingSubject] to any of string             
            in array[usingSencentence] according to condition.
        }
    }