求解释,我的代码哪里出错了
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Windows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e) //数字1
{
textBox1.Text = textBox1.Text + button1.Text;
}
private void button2_Click(object sender, EventArgs e) //数字2
{
textBox1.Text = textBox1.Text + button2.Text;
}
private void button3_Click(object sender, EventArgs e) //数字3
{
textBox1.Text = textBox1.Text + button3.Text;
}
private void button4_Click(object sender, EventArgs e) //数字4
{
textBox1.Text = textBox1.Text + button4.Text;
}
private void button5_Click(object sender, EventArgs e) //数字5
{
textBox1.Text = textBox1.Text + button5.Text;
}
private void button6_Click(object sender, EventArgs e) //数字6
{
textBox1.Text = textBox1.Text + button6.Text;
}
private void button7_Click(object sender, EventArgs e) //数字7
{
textBox1.Text = textBox1.Text + button7.Text;
}
private void button8_Click(object sender, EventArgs e) //数字8
{
textBox1.Text = textBox1.Text + button8.Text;
}
private void button9_Click(object sender, EventArgs e) //数字9
{
textBox1.Text = textBox1.Text + button9.Text;
}
private void button10_Click(object sender, EventArgs e) //数字0
{
textBox1.Text = textBox1.Text + button10.Text;
}
private void button11_Click(object sender, EventArgs e) //加号
{
jisuanqi j = new jisuanqi();
j.num1 = Convert.ToInt32(textBox1.Text);
j.type = "+";
textBox1.Text = "";
}
private void button12_Click(object sender, EventArgs e) //减号
{
jisuanqi j = new jisuanqi();
j.num1 = Convert.ToInt32(textBox1.Text);
j.type = "-";
textBox1.Text = "";
}
private void button13_Click(object sender, EventArgs e) //乘号
{
jisuanqi j = new jisuanqi();
j.num1 = Convert.ToInt32(textBox1.Text);
j.type = "*";
textBox1.Text = "";
}
private void button14_Click(object sender, EventArgs e) //除号
{
jisuanqi j = new jisuanqi();
j.num1 = Convert.ToInt32(textBox1.Text);
j.type = "/";
textBox1.Text = "";
}
private void button15_Click(object sender, EventArgs e) //开平方
{
jisuanqi j = new jisuanqi();
j.num1 = Convert.ToInt32(textBox1.Text);
j.type = "开平方";
textBox1.Text = "";
}
private void button16_Click(object sender, EventArgs e) //等号
{
int n;
jisuanqi j = new jisuanqi();
j.num2 = Convert.ToInt32(textBox1.Text);
if (j.type == button11.Text)
{
n = j.jiafa(j.num1,j.num2);
textBox1.Text = n.ToString();
}
else if (j.type ==button12.Text)
{
if (j.num2 == 0)
MessageBox.Show("分母不能为零");
else
{
n = j.jianfa(j.num1, j.num2);
textBox1.Text = n.ToString();
}
}
else if (j.type ==button13.Text)
{
n = j.chengfa(j.num1, j.num2);
textBox1.Text = n.ToString();
}
else if (j.type ==button14.Text)
{
n = j.chufa(j.num1, j.num2);
textBox1.Text = n.ToString();
}
else if (j.type == button15.Text)
{
if (j.num1 < 0)
MessageBox.Show("该数不能被开方");
else
{
double m = j.kaifang(j.num1);
textBox1.Text = m.ToString();
}
}
}
}
}
public class jisuanqi
{
public int num1;
public int num2;
public string type;
public int jiafa()
{
return num1 + num2;
}
public int jiafa(int a, int b)
{
this.num1 = a;
this.num2 = b;
return (num1 + num2);
}
public int jianfa()
{
return num1 - num2;
}
public int jianfa(int a, int b)
{
this.num1 = a;
this.num2 = b;
return (num1 - num2);
}
public int chengfa()
{
return num1 * num2;
}
public int chengfa(int a, int b)
{
this.num1 = a;
this.num2 = b;
return (num1 * num2);
}
public int chufa()
{
return num1 / num2;
}
public int chufa(int a, int b)
{
this.num1 = a;
this.num2 = b;
return (num1 / num2);
}
public double kaifang(int a)
{
this.num1 = a;
return Math.Sqrt(num1);
}
}
为什么我按等号它没有结果出来,求解释。。。。