c#编程—计算器

时间:2016-06-24 16:20:04
【文件属性】:

文件名称:c#编程—计算器

文件大小:65KB

文件格式:RAR

更新时间:2016-06-24 16:20:04

C#编程 计算器

本资源是用C#进行编程,实现计算其功能 //小数点点击事件 btn_dot.Click += (s, e) => { SetNum("."); btn_dot.Enabled = false; }; //C按钮点击事件 btn_c.Click += (s, e) => { tbx.Text = "0"; btn_dot.Enabled = true; Arithmetic.Clear(); }; //回退键点击事件 btn_backspace.Click += (s, e) => { if (tbx.Text.Length > 1) { if (tbx.Text.Substring(tbx.Text.Length - 1).Equals(".")) btn_dot.Enabled = true; tbx.Text = tbx.Text.Substring(0, tbx.Text.Length - 1); } else { tbx.Text = "0"; } }; //正负号点击事件 btn_pn.Click += (s, e) => { string symbol = tbx.Text.Substring(0, 1); if (symbol.Equals("-")) tbx.Text = tbx.Text.Replace(symbol, string.Empty); else tbx.Text = tbx.Text.Insert(0, "-"); }; //+、-、*、/、= btn_add.Click += (s, e) => { Operation("+"); }; btn_cut.Click += (s, e) => { Operation("-"); }; btn_divide.Click += (s, e) => { Operation("/"); }; btn_multiply.Click += (s, e) => { Operation("*"); }; btn_equal.Click += (s, e) => { Operation("="); Arithmetic.ClearSymbol(); }; } ///

/// 数字键、小数点点击事件具体处理函数 /// /// private void SetNum(string num) { if ((tbx.Text.Length == 1 && tbx.Text.Equals("0")) || hasOperated) { tbx.Text = num; if (tbx.Text.Equals(".")) tbx.Text = "0."; hasOperated = false; } else tbx.Text += num; }


【文件预览】:
WindowsCalculator
----Arithmetic.cs(989B)
----bin()
--------Debug()
----Form1.Designer.cs(13KB)
----Operator.cs(257B)
----AddOperator.cs(378B)
----Program.cs(505B)
----obj()
--------Debug()
----WindowsFormsApplication1.sln(937B)
----Form1.cs(4KB)
----OperatorManager.cs(964B)
----WindowsFormsApplication1.csproj.user(452B)
----MultiplyOperator.cs(329B)
----Form1.resx(6KB)
----WindowsFormsApplication1.csproj(6KB)
----WindowsFormsApplication1.suo(38KB)
----CutOperator.cs(324B)
----DivideOperator.cs(420B)
----Properties()
--------Resources.resx(5KB)
--------Settings.settings(249B)
--------AssemblyInfo.cs(1KB)
--------Settings.Designer.cs(1KB)
--------Resources.Designer.cs(3KB)

网友评论