【发布时间】:2018-09-10 00:52:27
【问题描述】:
它似乎只检测/检查列表中的第一个单词。
private bool ContentCheck()
{
List<string> FilteredWords = new List<string>()
{
"duck",
"donkey",
"horse",
"goat",
"dog",
"cat", //list of censored words
"lion",
"tiger",
"bear",
"crocodile",
"eel",
};
foreach (var e in FilteredWords)
{
if (memoEdit1.Text.Contains(e))
{
return true;
}
else
{
return false;
}
}
return false;
}
private void button_click (object sender, EventArgs e)
{
if (ContentCheck() == false)
{
//do something
}
else if (ContentCheck() == true)
{
MessageBox.Show("Error: Offensive word.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
【问题讨论】:
标签: c# list foreach textbox contains