WF数字计算6
2015-10-17 16:47
127 查看
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 数字和计算器 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string str1 = textBox1.Text;//取textBox1的值; string str2 = textBox2.Text;//取textBox2的值; int m1, m2; if(!int.TryParse(str1,out m1)) { // MessageBox.Show = "您好";//此种形式的是一个属性; MessageBox.Show("第一个数不是合法整数");//调用MessageBox的方法 return;//如果第一个出错就不能在继续执行下去了,必须要return退出函数 } if (int.TryParse(str1, out m2)==false)//等价与!int,TryParse(str1,out m1) { MessageBox.Show("第二个数不是合法整数"); return; } int m3 = m1 + m2; textBox3.Text = Convert.ToString(m3);//等价于 textBox3.Text=m3.ToString(); } } }
相关文章推荐
- 如何在java中实现List集合的遍历
- POJ 2105解题报告
- SynchronizationContext一篇
- 秦时明月-白雪
- jquery排除某个元素
- poj 1743(后缀数组)
- Android学习Broadcast Receiver(广播接收者) 注意事项
- android去掉 radio 或 checkBox 的默认图标,用自己的图标
- get post 区别
- WF累加求和5
- python 字符编码与解码——unicode、str和中文:UnicodeDecodeError: 'ascii' codec can't decode
- jQuery源码分析之jQuery.event.special八问
- 周期节
- 求一个数二进制位中有多少个 1 的不同解法
- SQL Server日志
- unity, 由于project settings中time scale变成0导致动画不播放
- 获取网上数据的两种方法HttpURLConnection和HttpClient
- hibenate 操作oracle 日期问题
- Asp.NET利用ClientScript.RegisterStartupScript("")的同学,请注意!
- WF静态成员4