Josip Pavic

Josip Pavic

  • NA
  • 20
  • 10.8k

Beginner problem

Nov 11 2011 9:21 AM
I now you would find this funny, but my problem is for loop. MessageBox display wrong result. cant figure out why??

                 int loopStart;
            int loopEnd;
            int answer = 0;

            loopStart = int.Parse(textBox1.Text);
            loopEnd = int.Parse(textBox2.Text);


            for (int i = loopStart; i < loopEnd; i++)
            {
                answer = answer + i;
            }

            MessageBox.Show(answer.ToString());


Thank for your help.
Jonny111

Answers (7)