asp.net 判断数组是否存在某个值的方法
程序员文章站
2024-03-07 14:58:09
方法一: 复制代码 代码如下: string str1 = "0,1,2,3,4,5,6 "; string[] str = str1.split( ', '); bool...
方法一:
string str1 = "0,1,2,3,4,5,6 ";
string[] str = str1.split( ', ');
bool hasflag=false;
foreach (string a in str)
{
if (a == "7 ")
{
hasflag=true;
break;
}
}
if(hasflag)
{ //执行当前页 }
else
{ //跳转 }
方法二
string [] flag = adminuser.flag.split('/');
list<string> list = new list<string>(flag);
if (list.contains("9"))
response.write("当前操作用户"+adminuser.username.tostring());
else
response.write("<script>alert('您无权限进行此项操作');location.href='admin_main.aspx'</script>");
复制代码 代码如下:
string str1 = "0,1,2,3,4,5,6 ";
string[] str = str1.split( ', ');
bool hasflag=false;
foreach (string a in str)
{
if (a == "7 ")
{
hasflag=true;
break;
}
}
if(hasflag)
{ //执行当前页 }
else
{ //跳转 }
方法二
复制代码 代码如下:
string [] flag = adminuser.flag.split('/');
list<string> list = new list<string>(flag);
if (list.contains("9"))
response.write("当前操作用户"+adminuser.username.tostring());
else
response.write("<script>alert('您无权限进行此项操作');location.href='admin_main.aspx'</script>");