C#中通过FORM窗体进行简单的加减乘除计算
- 如图

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 WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
string str1 = this.textBox1.Text;
string str2 = this.textBox2.Text;
string str3 = this.textBox3.Text;
int num1 = Convert.ToInt32(str1);
int num2 = Convert.ToInt32(str2);
int result = num1 + num2;
textBox3.Text = Convert.ToString(result);
}
private void button1_Click(object sender, EventArgs e)
{
string str1 = this.textBox1.Text;
string str2 = this.textBox2.Text;
string str3 = this.textBox3.Text;
int num1 = Convert.ToInt32(str1);
int num2 = Convert.ToInt32(str2);
int result = num1 -num2;
textBox3.Text = Convert.ToString(result);
}
private void button2_Click(object sender, EventArgs e)
{
string str1 = this.textBox1.Text;
string str2 = this.textBox2.Text;
string str3 = this.textBox3.Text;
int num1 = Convert.ToInt32(str1);
int num2 = Convert.ToInt32(str2);
int result = num1 *num2;
textBox3.Text = Convert.ToString(result);
}
private void button4_Click(object sender, EventArgs e)
{
string str1 = this.textBox1.Text;
string str2 = this.textBox2.Text;
string str3 = this.textBox3.Text;
int num1 = Convert.ToInt32(str1);
int num2 = Convert.ToInt32(str2);
double result = num1 /num2;
textBox3.Text = Convert.ToString(result);
}
}
}