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;
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
string wordToSearch = enterNameField.text;
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 if (badwords.Contains(wordToSearch))
badwords.All(wordToSearch.ToLower()
but noting seems to work.
Can anyone help me identify the issue here?
Thank you