- Home /
This question was
closed Dec 29, 2020 at 05:51 PM by
MidnightCoffeeInc for the following reason:
The question is answered, right answer was accepted
Question by
MidnightCoffeeInc · Dec 29, 2020 at 05:45 PM ·
c#strings
If String.Contains an item from List ?
For some reason, I can't find any info on this (though my Google skills might be lacking).
I'm trying to check if the name of a GameObject contains one of the words in a list of strings. I know I can use String.Contains() but how would I use this with a list?
Thanks!
Comment
Best Answer
Answer by sacredgeometry · Dec 29, 2020 at 05:50 PM
Something like?
bool containsItem;
foreach(var item in myList)
{
if(containsItem) break;
containsItem = myString.Contains(item);
}