Reputation: 55
I want to parse the content of my text_box to verify if my text contain each words of my textbox.
var answer = listanswer.Where(x => x.description.Contains(TextBox_1.Text));
if (answer.Count() == 1)
{
Interaction question = answer.First();
foreach (Choice choice in question.choices)
{
if (choice.status == "correct")
{
lb_input.Items.Add(choice.text);
}
}
}
Actually I check the total content of my text_box, I'm looking for a way to verify each words.
Any ideas ?
Upvotes: 2
Views: 169
Reputation: 460268
You need to split the text by white-space, then you can use Enumerable.All
:
string[] words = TextBox_1.Text.Split();
var answer = listanswer.Where(x => words.All(w => x.description.Contains(w)));
Upvotes: 3