日期:2014-05-20 浏览次数:20752 次
void Main() { string[] keys = new string[] { "about", "book", "carry", "crazy", "good", "old are", "windows" }; string[] inputarray = new string[] { "how old are you", "it is about 3", "I have a book", "carry", "it's time out", "a big box", "books", "linux" }; var query=from input in inputarray from ip in input.Split() let key=(from k in keys from k0 in k.Split() select k0) where key.Contains(ip) select input; foreach(var q in query.Distinct()) Console.WriteLine( q); /* how old are you it is about 3 I have a book carry */ }
------解决方案--------------------
var result=from p in inputarray
from q in input
let key=(from k in q.Split(' ') select k)
where p.Contains(key)
select p;