标题:C# 新手请求计算器中代码的解释
只看楼主
学士枫人
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-6-13
 问题点数:0 回复次数:4 
C# 新手请求计算器中代码的解释
public void RecordSign(string sign)//定义函数
        {
            FirstInput = true;
            
            if (LastSign == "")
            {
                OperandA = Convert.ToDouble(txtResult.Text);

            }
            else
            {
                operations();
                txtResult.Text = OperandA.ToString();
            }

            LastSign = sign;
        }
        private void btnPlus_Click(object sender, EventArgs e)
        {
            RecordSign("+");
        }
        private void btnSub_Click(object sender, EventArgs e)
        {
            RecordSign("-");
        }
        private void btnMul_Click(object sender, EventArgs e)
        {
            RecordSign("*");
        }
        private void btnDiv_Click(object sender, EventArgs e)
        {
            RecordSign("/");
        }
         请求 定义函数 中代码的解释;;;;;
       感谢!!!!!!1
搜索更多相关主题的帖子: 计算器 private 
2011-06-14 11:29
uhome
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-9-14
得分:0 
代码都不完整呀,operations()这个函数没给出来呀
2011-06-14 14:22
学士枫人
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2011-6-13
得分:0 
public void operations()
        {
            switch (LastSign)
            {
                case "+": OperandA += OperandB; break;
                case "-": OperandA -= OperandB; break;
                case "*": OperandA *= OperandB; break;
                case "/": OperandA /= OperandB; break;
                default:
                    break;
            }
        }


    谢谢有心人,对了 就是这个、、、
2011-06-14 17:35
xp白马飞马
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2011-8-7
得分:0 
我也是新手,
我的是这样写的
不知对你有没帮助
if (huhao == "+")
            {
                t.Text = (i + Convert.ToDecimal(t.Text)).ToString();
            }
            else if (huhao == "-")
            {
                t.Text = (i - Convert.ToDecimal(t.Text)).ToString();
            }
            else if (huhao == "*")
            {
                t.Text = (i * Convert.ToDecimal(t.Text)).ToString();
            }
            else if (huhao == "/")
            {
                if (t.Text == "0")
                {
                    MessageBox.Show("除数不为0");
                    dian = "NO";
                    myhuhao = "NO";
                    t.Text = "0";
                    i = 0;
                    huhao = "off";
                    return;
                }
                else
                {
                    t.Text = (i / Convert.ToDecimal(t.Text)).ToString();
                }
            }
2011-08-08 11:11
mydebug
Rank: 2
等 级:论坛游民
帖 子:16
专家分:41
注 册:2011-7-20
得分:0 
复杂了。
2011-08-13 12:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-342773-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.053260 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved