I am trying to do something like a if else condition in C#.
My below code is to check that all the text in text block is correct and show a display message.
if ((correctAns.Contains(textBlock1.Text)) &&
(correctAns.Contains(textBlock2.Text)) &&
(correctAns.Contains(textBlock3.Text)) &&
(correctAns.Contains(textBlock4.Text)) &&
(correctAns.Contains(textBlock5.Text)))
{
//If it contains the correct answer
MessageBox.Show("All correct");
}
What i want for now is to check if any 3 of the text in the text block is correct will show a message box.
How should i go about doing it?
Count them.
If your code matches the entire problem, this is probably the most straight-forward – but if the number of text blocks grow, you might want to re-think the solution: