Hello everyone, I've been working around this for to long. I have this code to search for a specific string from an array. This array gets its values from a txt file: Each word in the txt file is separated by a new line; Code (CSharp): public InputField enterNameField; public TextAsset badWordsFile; string[] badwords = badWordsFile.text.Split('\n'); With that a creat a string named "WordToSearch", that is the text fomr the inputfield Code (CSharp): string wordToSearch = enterNameField.text; Code (CSharp): if (badwords.Any(wordToSearch.ToLower().Contains)) { print("Word Found: " + wordToSearch); } else { print("No word found"); } The issue is that this returns true all the time, no matter what is in the inputflied. I already tried Code (CSharp): if (badwords.Contains(wordToSearch)) Code (CSharp): badwords.All(wordToSearch.ToLower() but noting seems to work. Can anyone help me identify the issue here? Thank you
array.Any and array.All take a LINQ Predicate as input, which you're not doing. Either use a Predicate or just loop through the array the old fashioned way. (Google how to write a LINQ Predicate for more info) Code (csharp): bool naughtyWord = false; foreach (string word in badwords) { if (word == wordToSearch.ToLower()) { naughtyWord = true; } }