求用c#程序语言编写的计算器的程序代码

来源:百度知道 编辑:UC知道 时间:2024/05/16 08:31:28
最好是我能看得懂的,申明:本人刚刚开始学习编程

//后台代码
protected void Button1_Click(object sender, EventArgs e)
{
double sum = 0;
double one = 0;
double two = 0;
try
{
one = Convert.ToInt32(this.txtOne.Text.ToString());
two = Convert.ToInt32(this.txtTwo.Text.ToString());
}
catch
{

lblSum.Text="输入值必须为数字!";
return;

}
string oper = this.DropDownList1.Text.ToString();
switch (oper)
{
case "+":
sum = one + two;
break;
case "-":
sum = one - two;
break;
case "*":
sum = one * two;
break;
case "/":
sum = one / two;