I want to be able to check if the string contains all the values held in the list; So it will only give you a \'correct answer\' if you have all the \'key words\' from the l
You can use some of the LINQ methods like:
if(Keywords.All(k => textBox1.Text.Contains(k))) {
correct += 1;
MessageBox.Show("Correct");
} else {
incorrect -= 1;
MessageBox.Show("Incorrect");
}
The All method returns true when the function returns true for all of the items in the list.
Using LINQ:
// case insensitive check to eliminate user input case differences
var invariantText = textBox1.Text.ToUpperInvariant();
bool matches = KeyWords.All(kw => invariantText.Contains(kw.ToUpperInvariant()));
This should help:
string text = "Psychology is the study of mental process and behaviour of humans";
bool containsAllKeyWords = KeyWords.All(text.Contains);