调试一下。comboYunSfu,这是个combobox么?
comboYunSfu.ToString()得到的是类型的名字。
你需要写
switch (comboYunSfu.Text.Trim())

解决方案 »

  1.   

     switch (comboYunSfu.ToString())comboYunSfu 你这个只是一个下拉控件(如果没猜错的话)的对象~
    他还有text属性是当前显示的值~
      

  2.   

    断点调试,看comboYunSfu.ToString()是多少?
      

  3.   

    switch (comboYunSfu.ToString())
    这里有问题,你自己单步调试就知道啦
    帮你改一下
        if (textBox1.Text == "" || comboBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("不能有空值", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    double one = double.Parse(textBox1.Text);
                    double two = double.Parse(textBox2.Text);                switch (comboBox1.text)
                    {
                        case "+":
                            label4.Text= Convert.ToString(one + two);
                            break;
                        case "-":
                            label4.Text = Convert.ToString(one - two);
                            break;
                    }
                }
      

  4.   

    string.IsNullOrEmpty(txtfirstcount.Text)
    单步跟踪调试值
    public class Operation  
    {  
    private double _numberA = 0;  
    private double _numberB = 0;  
    public double NumberA  
    {  
    get  
    {  
    return _numberA;  
    }  
    set  
    {  
    _numberA = value;  
    }  
    }  
    public double NumberB  
    {  
    get  
    {  
    return _numberB;  
    }  
    set  
    {  
    _numberB = value;  
    }  
    }  
    public virtual double GetResult()  
    {  
    double result = 0;  
    return result;  
    }  
    public static string checkNumberInput(string currentNumber, string inputString)  
    {  
    string result = "";  
    if (inputString == ".")  
    {  
    if (currentNumber.IndexOf(".") < 0)  
    {  
    if (currentNumber.Length == 0)  
    result = "0" + inputString;  
    else  
    result = currentNumber + inputString;  
    }  
    }  
    else if (currentNumber == "0")  
    {  
    result = inputString;  
    }  
    else  
    {  
    result = currentNumber + inputString;  
    }  return result;  
    }  
    }  
    class OperationAdd : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    result = NumberA + NumberB;  
    return result;  
    }  
    }  
    class OperationSub : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    result = NumberA - NumberB;  
    return result;  
    }  
    }  
    class OperationMul : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    result = NumberA * NumberB;  
    return result;  
    }  
    }  
    class OperationDiv : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    if (NumberB == 0)  
    throw new Exception("除数不能为0。");  
    result = NumberA / NumberB;  
    return result;  
    }  
    }  
    class OperationSqr : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    result = NumberB * NumberB;  
    return result;  
    }  
    }  
    class OperationSqrt : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    if (NumberB < 0)  
    throw new Exception("负数不能开平方根。");  
    result = Math.Sqrt(NumberB);  
    return result;  
    }  
    }  
    class OperationReverse : Operation  
    {  
    public override double GetResult()  
    {  
    double result = 0;  
    result = -NumberB;  
    return result;  
    }  
    }  
    public class OperationFactory  
    {  
    public static Operation createOperate(string operate)  
    {  
    Operation oper = null;  
    switch (operate)  
    {  
    case "+":  
    {  
    oper = new OperationAdd();  
    break;  
    }  
    case "-":  
    {  
    oper = new OperationSub();  
    break;  
    }  
    case "*":  
    {  
    oper = new OperationMul();  
    break;  
    }  
    case "/":  
    {  
    oper = new OperationDiv();  
    break;  
    }  
    case "sqr":  
    {  
    oper = new OperationSqr();  
    break;  
    }  
    case "sqrt":  
    {  
    oper = new OperationSqrt();  
    break;  
    }  
    case "+/-":  
    {  
    oper = new OperationReverse();  
    break;  
    }  
    }  return oper;  
    }  
    private void buttonAdd_Click(object sender, EventArgs e)  
    {  
    if (txtShow.Text != "")  
    {  
    oper = OperationFactory.createOperate(((Button)sender).Text);  oper.NumberA = Convert.ToDouble(txtShow.Text);  bOperate = true;  
    }  
    }  
    private void buttonEqual_Click(object sender, EventArgs e)  
    {  
    if (txtShow.Text != "")  
    {  
    if (((Button)sender).Text != "=")  
    {  
    oper = OperationFactory.createOperate(((Button)sender).Text);  
    }  
    oper.NumberB = Convert.ToDouble(txtShow.Text);  
    txtShow.Text = oper.GetResult().ToString();  
    bOperate = true;  
    }  
    }  
      

  5.   

    学会用 .toString().Trim() 和 convertInt32及转换类的方法.............
      

  6.   

    switch (comboYunSfu.ToString())
    这句有问题,其实只要简单调试一下就会发现。
      

  7.   

    switch (comboYunSfu.SelectedText.ToString())