title: Adding numbers from 1 to N in C#
body: <p>I'm writing code in C# and trying to add all of the numbers between the number 1 and N, N being the number that is inputted in a textbox.  I'm doing this, at least trying to do this, by putting it into a while loop.</p>
  
  <p>I have added all the numbers between 2 textboxes before but for some reason I'm driving myself crazy and can't figure this out. I'm a beginning programmer so please be gentle.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Edit:
  One of the six thousand things I've tried.  I think this has me in an infinite loop?</p>
  
  <pre><code>       private void btnAddAll_Click(object sender, EventArgs e)
         {
             int n;
             int count = 0;
             int answer = 0;
  
             n = int.Parse(txtNum.Text);
  
             count = n;
  
             while (count &gt;= 1)
             {
                 answer = answer + count;
                 count++;
             }
                 lstShow.Items.Add("Sum = " + answer);
                 lstShow.Text = answer.ToString();
         }
  </code></pre>