using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "=";
button1.Text = "运算";
comboBox1.Items.Add("+");
comboBox1.Items.Add("-");
comboBox1.Items.Add("*");
comboBox1.Items.Add("/");
}
string text;
private void button1_Click(object sender, EventArgs e)
{
switch (comboBox1.Text)
{
case "+":
text = (double.Parse(textBox1.Text) + double.Parse(textBox2.Text)).ToString();
break;
case "-":
text = (double.Parse(textBox1.Text) - double.Parse(textBox2.Text)).ToString();
break;
case "*":
text = (double.Parse(textBox1.Text) * double.Parse(textBox2.Text)).ToString();
break;
case "/":
text = (double.Parse(textBox1.Text) / double.Parse(textBox2.Text)).ToString();
break;
default:
break;
}
textBox3.Text = text;
}
}
}