using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
double x = double.Parse(textBox1.Text);
double y = double.Parse(textBox2.Text);
double z;
if (radioButton1.Checked) z = x + y;
else if (radioButton2.Checked) z = x - y;
else if (radioButton3.Checked) z = x * y;
else z = x / y;
textBox3.Text = z.ToString();
}
&nb

这是一个使用C#编写的ASP.NET简单计算器程序。它包括两个输入框用于输入数字,一组单选按钮选择运算类型(加、减、乘、除),以及一个结果显示文本框。当点击计算按钮时,程序会检查输入是否为有效数字,并根据选定的运算符进行相应的计算,将结果显示在文本框中。如果输入无效或运算出错,程序会清除输入并显示错误提示。

390

被折叠的 条评论
为什么被折叠?



