设计计算器遇到问题
我是刚刚学C#的,老师说要我们设计个计算器,实现加法这步,“为Form1类增加一个变量double sum=0,记录部分和”这个咋弄啊?我不懂在哪添加哦
程序代码:using System;
using System.Collections.Generic;
using using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace 加法计算器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double sum = 0;
double t1 = Convert.ToDouble(textBox1.Text);
double t2 = Convert.ToDouble(textBox2.Text);
sum = t1 + t2;
textBox3.Text = sum.ToString();
}
}
}简单做了个,看看吧,全代码在附件。