C#/.NET如何判断一个字符是否包含在另一个字符里面
发布网友
发布时间:2024-04-28 23:14
我来回答
共5个回答
热心网友
时间:2024-05-04 11:52
string str1 = "ac,ab,b,cd" ;
string str2 = "a";
string[] str = str1.Split(',');
for (int i = 0; i < str.Length; i++)
{
if (str[i].Contains(str2))
Response.Write(str[i] + " " + "contains" + " " + str2 + ".");
else
Response.Write(str[i] + " " + "does not contain" + " " + str2 + ".");
}
热心网友
时间:2024-05-04 11:52
string str1 = "123456789";
string str2 = "456";
bool b = str1.Contains(str2);
热心网友
时间:2024-05-04 11:53
定义变量字符串数组s
s=str1.Split(",")
用foreach循环,
依次检查s数组里的每个字符串是否等于str2,然后处理
热心网友
时间:2024-05-04 11:53
string str1 = "ac,ab,b,cd" ;
string str2 = "a";
string[] str = str1.Split(',');
for (int i = 0; i < str.Length; i++)
{
if (str[i].Contains(str2))
Response.Write(str[i] + " " + "contains" + " " + str2 + ".");
else
Response.Write(str[i] + " " + "does not contain" + " " + str2 + ".");
}
热心网友
时间:2024-05-04 11:52
string str1 = "ac,ab,b,cd" ;
string str2 = "a";
string[] str = str1.Split(',');
for (int i = 0; i < str.Length; i++)
{
if (str[i].Contains(str2))
Response.Write(str[i] + " " + "contains" + " " + str2 + ".");
else
Response.Write(str[i] + " " + "does not contain" + " " + str2 + ".");
}
热心网友
时间:2024-05-04 11:53
string str1 = "123456789";
string str2 = "456";
bool b = str1.Contains(str2);
热心网友
时间:2024-05-04 11:53
定义变量字符串数组s
s=str1.Split(",")
用foreach循环,
依次检查s数组里的每个字符串是否等于str2,然后处理
热心网友
时间:2024-05-04 11:54
string str1 = "ab,ac,b,ad";
string str2 = "a";
string[] tempArray = str1.Split(',');
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (string str in tempArray)
list.Add(str);
Response.Write(list.Contains(str2));
热心网友
时间:2024-05-04 11:54
string s;//原字符串
string ss;//包含字符串
bool b=s.Contains("ss");//返回一个布尔值
if(b==true)
//说明包含
else
//不包含
热心网友
时间:2024-05-04 11:53
string str1 = "123456789";
string str2 = "456";
bool b = str1.Contains(str2);
热心网友
时间:2024-05-04 11:54
定义变量字符串数组s
s=str1.Split(",")
用foreach循环,
依次检查s数组里的每个字符串是否等于str2,然后处理
热心网友
时间:2024-05-04 11:54
string str1 = "ab,ac,b,ad";
string str2 = "a";
string[] tempArray = str1.Split(',');
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (string str in tempArray)
list.Add(str);
Response.Write(list.Contains(str2));
热心网友
时间:2024-05-04 11:55
string s;//原字符串
string ss;//包含字符串
bool b=s.Contains("ss");//返回一个布尔值
if(b==true)
//说明包含
else
//不包含
热心网友
时间:2024-05-04 11:54
string str1 = "ab,ac,b,ad";
string str2 = "a";
string[] tempArray = str1.Split(',');
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
foreach (string str in tempArray)
list.Add(str);
Response.Write(list.Contains(str2));
热心网友
时间:2024-05-04 11:54
string s;//原字符串
string ss;//包含字符串
bool b=s.Contains("ss");//返回一个布尔值
if(b==true)
//说明包含
else
//不包含