//容易,用String類的Contains方法就可以判斷,具體看例子。
using System;
public class Test
{
public static void Main(string[] args)
string line="aaa 你好 哈哈哈 對了 good bye just so so so easy!";
string[] strs={"aaa","sos","哈哈哈","對了嗎","so easy"};
foreach(string s in strs)
if(line.Contains(s))
Console.WriteLine("字串\""+line+"\"包含字串\""+s+"\"");
}
else
Console.WriteLine("字串\""+line+"\"不包含字串\""+s+"\"");
Console.Write("Press any key to continue . . . ");
Console.ReadLine();
//容易,用String類的Contains方法就可以判斷,具體看例子。
using System;
public class Test
{
public static void Main(string[] args)
{
string line="aaa 你好 哈哈哈 對了 good bye just so so so easy!";
string[] strs={"aaa","sos","哈哈哈","對了嗎","so easy"};
foreach(string s in strs)
{
if(line.Contains(s))
{
Console.WriteLine("字串\""+line+"\"包含字串\""+s+"\"");
}
else
{
Console.WriteLine("字串\""+line+"\"不包含字串\""+s+"\"");
}
}
Console.Write("Press any key to continue . . . ");
Console.ReadLine();
}
}