62,041
社区成员
发帖
与我相关
我的任务
分享
bool isExist = true;
string s = "1,2,3,4,5,6";
string temps = "," + s + ",";
string a = "2,8";
string[] tempa = a.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
foreach (string stra in tempa)
{
if (temps.IndexOf(stra) == -1)
{
isExist = false;
break;
}
}
bool isExist = true;
string s = "1,2,3,4,5,6";
string[] temps = s.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
string a = "2";
string[] tempa = a.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
foreach (string stra in tempa)
{
if (!temps.Contains(stra))
{
isExist = false;
break;
}
}
public bool IsContains(mainStr, subStr){
//string mainStr = "1,2,3,4,5,6";
//string subStr = "2,4,6";
foreach(char ch in subStr){
if(ch == ',')continue;
if(mainStr.Contains(ch.ToString())){
return true;
}
}
return false;
}
string s = "1,2,3,4,5,6";
if(s.IndexOf("2,3")>-1)
{
Response.Write("存在!");
}
string tmp=","+s+",";
if(tmp.indexOf(","+a+",")!=-1){
Response.Write("字符串s中包含字符串a");
}else{
Response.Write("字符串s中不包含字符串a");
}