我先给一个Session变量赋值 Session[ "adminCid "]=dr[ "cid "].ToString();
这个cid在数据库中是键值 int类型
我在其他页读取这个session 比如说这时Session[ "adminCid "] = 1
switch(Session[ "adminCid "]){
case 0 : Response.Write( "关闭权限 ");
break;
case 1 : Response.Write( "系统管理员 ");
break;
case 2 : Response.Write( "一级用户 ");
break;
case 3 : Response.Write( "二级用户 ");
break;
}
但是系统报错:Compiler Error Message: CS0151: A value of an integral type expected
Line 52: switch(Session[ "adminCid "]){
应该怎么解决啊?
------解决方案--------------------------------------------------------
Convert.ToInt32(Session[ "adminCid "].ToString())
------解决方案--------------------------------------------------------
要保证Session[ "adminCid "]不为空