Console.WriteLine("请输入你想说的一句话");
string say = Console.ReadLine();
string[] words = { "TMD","NND","SB"};//定义禁用词汇数组
int i;
for (i = 0; i < words.Length; i++)
{
if (say.Contains(words[i])) //检查say中是否包含禁用词汇
{
say = say.Replace(words[i], "***");
}
}
Console.WriteLine("输入数据是:{0}", say);
能让检查不区分大小写吗 像s1.Equals(s2, StringComparison.OrdinalIgnoreCase),两个字符串进行比较不区分大小写的比较。 |