C#上机 第十周 运算器

来源:互联网 发布:app美图软件 编辑:程序博客网 时间:2024/06/14 08:40
/* * 程序头部注释开始   * 程序的版权和版本声明部分   * Copyright (c) 2011, 烟台大学计算机学院学生   * All rights reserved.   * 文件名称: 运算器                      * 作    者:薛广晨                               * 完成日期:2012  年 11 月  12  日   * 版 本号:x1.0               * 对任务及求解方法的描述部分   * 输入描述:  * 问题描述: * 程序输出:   * 程序头部的注释结束 */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 WindowsFormsApplication4{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0)            {                MessageBox.Show("请输入数!");                return;            }            try            {                double x = double.Parse(textBox1.Text);                double y = double.Parse(textBox2.Text);                textBox3.Text = (x + y).ToString();            }            catch (Exception ex)            {                MessageBox.Show(ex.Message);            }        }    }}


运行结果:

原创粉丝点击