我正在尝试通过“过滤器”列表过滤字符串集合......坏词列表。该字符串包含列表中我不想要的单词。
我到目前为止,这里的坏词是“frakk”:
string[] filter = { "bad", "words", "frakk" };
string[] foo =
{
"this is a lol string that is allowed",
"this is another lol frakk string that is not allowed!"
};
var items = from item in foo
where (item.IndexOf( (from f in filter select f).ToString() ) == 0)
select item;
但这不起作用,为什么?