摘要: 原理:假设取3位小数1、2.444442、得到0.000553、1+2=2.445004、得到2.445 /// /// 计算double值四舍五入的方法 /// /// 进行四舍五入的数值 /// 保留的小数位 /// 返回四舍五入后的double值 internal double Round(double dbl, int i) { string P_str_dbl = dbl.ToString();//将double数值转换为字符串 strin... 阅读全文
posted @ 2014-02-14 16:32 蚂蚁拉车 阅读(346) 评论(0) 推荐(0) 编辑
摘要: private void btn_GetCount_Click(object sender, EventArgs e) { int P_scalar = 0;//定义值类型变量并赋值为0 Regex P_regex = //创建正则表达式对象,用于判断字符是否为汉字 new Regex("^[\u4E00-\u9FA5]{0,}$"); for (int i = 0; i < txt_str.Text.Length; i++)//遍历字符串中每一个字符 { ... 阅读全文
posted @ 2014-02-14 11:40 蚂蚁拉车 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 主要内容是下面两行代码:取得文本的第一个字母的编码。string P_str_temp = "abc";string P_str = Encoding.GetEncoding("unicode").GetBytes(new char[] { P_str_temp[0] })[0].ToString();具体事件如下: private void btn_ToASCII_Click(object sender, EventArgs e) { if (txt_char.Text != string.Empty)//判断输入是否为空 { ... 阅读全文
posted @ 2014-02-14 10:57 蚂蚁拉车 阅读(698) 评论(0) 推荐(0) 编辑
摘要: 要点在于按钮的布局和对控件的使用及删除namespace NumberGame{ public partial class Form1 : Form { public Form1() { InitializeComponent(); T_time.Interval = 1; } Random G_random = new Random(); int G_int_num = 0; DateTime G_time_time; /// ... 阅读全文
posted @ 2014-02-14 10:04 蚂蚁拉车 阅读(182) 评论(0) 推荐(0) 编辑