在Form1窗体中有一个名称为textBox1的文本框和一个名称为button1的命令按钮。编写适当的事件过程,使得程序运行后,

在Form1窗体中有一个名称为textBox1的文本框和一个名称为button1的命令按钮。
编写适当的事件过程,使得程序运行后,单击button1按钮,计算表达式s=1+(1+2)+(1+2+3)+...+(1+2+3+...+20)的值,并将计算结果显示在textBox1文本框中。
【正确答案】:private void buttonl_Click(object sender,EventArgs e) 
{
int i,s=0,p=0;
for(i=1;i<=20;i++) 
{
p+=i; 
s=s+p; 
}
textBox1.Text=Convert.ToString(s); 
}