title: Creating an instance of an object within an if in C#
body: <p>Can I create an instance of an object within an if statement?
  I've made 2 checkboxes in order to controll which constructor I use, but i get the error message " The name "mth" does not exist in the current context " </p>
  
  <pre><code>if (checkBox1.Checked &amp;&amp; checkBox2.Checked)
          {
              Facto mth = new Facto(label3, wait_time, progressBar1);
          }
          else if(checkBox1.Checked==false &amp;&amp; checkBox2.Checked)
          {
              Facto mth = new Facto(label3,wait_time);
          }
          else if (checkBox1.Checked &amp;&amp; checkBox2.Checked == false)
          {
              checkBox1.Checked = false;
              Facto mth = new Facto();
          }
          else
          {
              Facto mth = new Facto();
          }
  
  
          int result = mth.Factorial(number);
  </code></pre>
  
  <p>What am I doing wrong? I'm new to C# and I don't really have the hang of it yet.
  Any help would be appreciated.
  Thanks in advance.</p>