各位下午好:
      我碰到一个问题,请大家解决。
      我用到了switch case语句,来选择很多项。在每项后又分成两项,是判断真假的,如果真执行1,如果假执行2。该怎么写啊?          谢谢!!!

解决方案 »

  1.   

    swtich (m)
    {
     case 1:
       {
           if (n==1) {} else {}
       }
       break;
    }
      

  2.   

    switch (s){
    case "chanpin":
       if (this.chap.Visible == true) 
    {
    this.chap.Visible=false;
    }
    else
    {
         this.chap.Visible =true;

    }
           case "dingdan":
    if (this.chap.Visible == true) 
    {
    this.chap.Visible=false;
    }
    else
    {
    this.chap.Visible =true;
             }
    }
    它总是提示控制不能从一个 case 标签(“case "chanpin":”)贯穿到另一个 case 标签;
    控制不能从一个 case 标签(“case "dingdan":”)贯穿到另一个 case 标签
    请教大家,不胜感激!
      

  3.   

    switch (s){
    case "chanpin":
       if (this.chap.Visible == true) 
    {
    this.chap.Visible=false;
    }
    else
    {
         this.chap.Visible =true;

    }
            break;//添加break
           case "dingdan":
    if (this.chap.Visible == true) 
    {
    this.chap.Visible=false;
    }
    else
    {
    this.chap.Visible =true;
             }
             break; //添加上break;
    }
      

  4.   

    呵呵,switch怎么可以没有break?
      

  5.   

    break 啊,以后要小心哦~~~