这个switch错在哪儿了?

来源:百度知道 编辑:UC知道 时间:2024/05/10 17:53:40
var act=new String(Request("act"))

switch (act)
{
case "add":Response.Write(1);
break;
case "edit":Response.Write(2);
break;
case "del":Response.Write(3);
break;
default:Response.Write(4);
break;
}

结果都是打印4不对啊,用if。。。else 通过了
act就是char型的捏

楼主你错了...act不是char 型的...而是 字符串类型的..

楼主改一下...把判断条件改成是 char int short byte 等等类型的..

祝楼主早日成功!

你这前面的条件都不满足,肯定执行default啦。
这是什么语言啊,怎么还有这语法:var act=new String(Request("act"))
还有 case "add" 得改成 case "a" ,既改成char型。

switch()的参数只能是int short char还有什么型 我忘了
反正不能使 var型的