



public void Calc_Sum(int A, int B, int C)
{
Double dSum = 0;
textBox3.Text = "";
for (int i = A; i <= B; i += C)
{
dSum += i;
textBox3.AppendText(i + " + ");
}
textBox3.Text = textBox3.Text.Substring(0, textBox3.TextLength - 2);
textBox3.AppendText(" = " + dSum);
}
private void button1_Click(object sender, EventArgs e)
{
int iStart, iEnd;
Double dSum = 0;
iStart = int.Parse(textBox1.Text);
iEnd = int.Parse(textBox2.Text);
if (iStart % 2 == 0)
iStart++;
Calc_Sum(iStart, iEnd, 2);
}
private void button2_Click(object sender, EventArgs e)
{
int iStart, iEnd;
Double dSum = 0;
iStart = int.Parse(textBox1.Text);
iEnd = int.Parse(textBox2.Text);
if (iStart % 2 == 1)
iStart++;
Calc_Sum(iStart, iEnd, 2);
}
private void button3_Click(object sender, EventArgs e)
{
int iStart, iEnd;
Double dSum = 0;
iStart = int.Parse(textBox1.Text);
iEnd = int.Parse(textBox2.Text);
Calc_Sum(iStart, iEnd, 1);
}