我有一个字符串如何检查字符串列表是否与短语中的所有单词匹配?
string[] arr = new string[] { "hello world", "how are you", "what is going on" };
的名单,我需要检查,如果我给字符串使用的每一个字中的一个字符串在arr
让我们说,我有
string s = "hello are going on";
这将是一个匹配,因为s
中的所有单词都在arr
string s = "hello world man"
这个人会不会是一个比赛,因为“人”是不是在任何字符串的arr
我知道怎么写了“长”的方式来做到这一点,但有一个很好的LINQ查询,我可以写吗?
+1:优雅,简单,好看。 SelectMany不需要像Nathan和我一样!你可以像我在我的回答中那样使用函数或Func委托来事件一行。 – Larry 2013-03-13 19:18:42