C#简单计算器源码
程序员文章站
2022-07-16 19:02:11
...
C#简单计算器源码:
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 简单计算器
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//string v = this.ProductName;
//this.UseWaitCursor = new bool();
int num1 = Convert.ToInt32(textBox1.Text);
int num2 = Convert.ToInt32(textBox2.Text);
string type = comboBox1.SelectedItem.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
int num1 = Convert.ToInt32(textBox1.Text);
int num2 = Convert.ToInt32(textBox2.Text);
string type = comboBox1.SelectedItem.ToString();
if (type=="+")
{
int sum = num1 + num2;
label2.Text = Convert.ToString(sum);
}
if (type == "-")
{
int sum = num1 - num2;
label2.Text = Convert.ToString(sum);
}
if (type == "*")
{
int sum = num1 * num2;
label2.Text = Convert.ToString(sum);
}
if (type == "/")
{
int sum = num1 / num2;
label2.Text = Convert.ToString(sum);
}
}
}
}
运行结果:
上一篇: 简易计算器 (C语言)作业
下一篇: 机器学习-数据归一化