首先设计如下界面:
编写如下代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace aa
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button5_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1 .Text );
double y = Convert.ToDouble (textBox2 .Text );
double result=Math.Pow (x,y);
label3.Text = textBox1 .Text +“的”+textBox2 .Text +“次方为”+result ;
}
private void button1_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1.Text);
double y = Convert.ToDouble(textBox2.Text);
double result = x+y;
label3.Text = textBox1.Text + “+” + textBox2.Text + “的值为” + result;
}
private void button2_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1.Text);
double y = Convert.ToDouble(textBox2.Text);
double result = x – y;
label3.Text = textBox1.Text + “-“ + textBox2.Text + “的值为” + result;
}
private void button3_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1.Text);
double y = Convert.ToDouble(textBox2.Text);
double result = x * y;
label3.Text = textBox1.Text + “*” + textBox2.Text + “的值为” + result;
}
private void button4_Click(object sender, EventArgs e)
{
double x = Convert.ToDouble(textBox1.Text);
double y = Convert.ToDouble(textBox2.Text);
double result = x /y;
label3.Text = textBox1.Text + “/” + textBox2.Text + “的值为” + result;
}
}
}
运行结果:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!