日期:2014-05-18  浏览次数:20729 次

计算器2------C#窗体
 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

 

namespace form1

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private int  op1, op2, re;

        private char op;

        private void button2_Click(object sender, EventArgs e)

        {

            this.textBox1.Text = "";

            this.textBox2.Text = "";

            this.textBox3.Text = "";

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            op1 = int.Parse(this.textBox1.Text);

            op2 = int.Parse(this.textBox2.Text);

 

            if (radioButton1.Checked == true)

            {

                re = op1 + op2;

                this.textBox3.Text = re.ToString();

            }

            if (radioButton2.Checked == true)

            {

                re = op1- op2;

                this.textBox3.Text = re.ToString();

            }

            if (radioButton3.Checked == true)

            {

                re = op1 * op2;

                this.textBox3.Text = re.ToString();

            }

            if (radioButton4.Checked == true)

            {

                re = op1 /op2;

                this.textBox3.Text = re.ToString();

            }

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

 

        }

    }

}