title: If-else statement with radio buttons and a for loop
body: <p>I've gotten an issue that keeps happening and I'm unsure what the problem is. I need to create a program in Microsoft Visual studio where radioButton1 is for finding the sum of consecutive numbers and radioButton2 is for finding the factorial of a number. </p>
  
  <p>There will be three buttons, one for FOR loop, one for WHILE loop, and one for DO-WHILE loop. I'm working on the FOR button. </p>
  
  <p>What I'm trying to do is by making a selection, then pressing one of the buttons, it'll find the answer using the loop clicked in a Message box. </p>
  
  <p>This is what I've gotten so far:</p>
  
  <pre><code>private void button1_Click(object sender, System.EventArgs e)
  {
    if ((radioButton1.Checked == true) &amp;&amp; (radioButton2.Checked == false))
    {
      int sum = 0;
      int number = int.Parse(numericUpDown1.Value.ToString());
      for (int i = 1; i &lt;= number; i++)
      {
        sum = sum + i;
        MessageBox.Show("The sum of the consecutive numbers leading up to " + number + " is " + sum + ".");
      }
      MessageBox.Show("The sum of the consecutive numbers leading up to " + number + " is " + sum + ".");
    }
    else if ((radioButton2.Checked == true) &amp;&amp; (radioButton1.Checked == false))
    {
      int product = 1;
      int number = int.Parse(numericUpDown1.Value.ToString());
      for (int i = 1; i &lt;= number; i++)
      {
        product *= i;
        MessageBox.Show("The factorial of the numbers leading up to " + number + " is " + product + ".");
      }
      MessageBox.Show("The factorial of the numbers leading up to " + number + " is " + product + ".");
    }
    else
    {
      MessageBox.Show("Invalid");
    }
  }
  </code></pre>
  
  <p>I keep receiving this message:</p>
  
  <p>"'Lab5'does not contain a definition for 'radioButton2.CheckedChanged' and no extension method 'radioButton2.CheckChanged' accepting a first argument of type 'Lab5' could be found (are you missing a using directive or an assembly reference?)."</p>
  
  <p>And I honestly have no idea what that means. </p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>I want to keep it in an if-else statement simply because I don't want the message box for radioButton1 to pop up when radioButton2 is selected.</p>