how do i check if a list contains elements from another list?

Hi everyone. I’m doing a app in unity using database and i need to check the information (string) conteined in my database to set some toggles on. How can I do that? I’m stuck on something like this:

public List allExercises = new List<GameObject>();
public string[] exercisesSplitString;

public void LoadData(){
foreach(string c in exercisesSplitString)
                    Debug.Log("length: " + exercisesSplitString.Length);
                    Debug.Log("c: " + c);

i need to check if there’s any matching elements from ‘exercisesSplitString’ and ‘allExercises’ (the object names) so I can turn on the toggles from the elements in ‘allExercises’ that matches.

hope that makes sense. that’s not the entire code but i think it’ll do. i’m using the debugs just to check if the foreach is working properly because it wasn’t.

thank you!

Just iterate over array and check if “allExercises” has got any value that is in “exercisesSplitString” by function with for loop (foreach loop is slower):

private bool ArrayValueInList()
    for(int i = 0 ; i < exercisesSplitString.Length ; i++)

return true;
return false;