Compliance with the mark in two (or more) checkBox'ach
-
I'm doing a study program, something like a classroom writing a C# test, checkboxes, three levels of difficulty:
1. Selection of one option from the five submissions;
2. Two (or more) options simultaneously;
3. Introduce a follow-up check to the correctness.
Standard, actually. The simplest level was easiest, the hardest.
Is that how to ensure that the correctness of the reply is met when two or three correct answers are to be selected at the same time?
Trying to do this:int rcount = 0; // число правильных ответов string right1 = ""; string right2 = ""; // определяем правильные ответы .... private void button1_Click(object sender, EventArgs e) { CheckBox[] CB = { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5 }; foreach (CheckBox cb in CB) { if (cb.Checked && cb.Text == right1 && cb.Text == right2) rcount++; } }
but it doesn't come out, the condition is not met.
rcount
Not increasing. The code that is down is chequebox interviews and variables.right1
andright2
corresponds to correct responses. And if the right options are chosen, we need an increase in the correct answers. Apparently, it's a stupid question, but I don't know how to make it work. Please indicate how to make the condition met under two or more options?
-
You've got a mission that says
двух (или более) вариантов
- it means that there is a need to define a body/box for options, not a separate right* for each option.p.s.
Added. https://ru.stackoverflow.com/a/475585/196972 - WinForms Annex, which indicate any number of questions and correct answers.