Hy,我想从一个集合中找到一个包含例如“30天” 。 我想首先搜索“30”然后搜索“days”。 我应该如何使用lambda表达式?有人可以举个例子吗?
由于
答案 0 :(得分:0)
string search = "30 days";
var result = MyEnumerable.Where(x=>search.Split(' ').Contains(x.fieldToSearch))
答案 1 :(得分:0)
试试这个:
var search = "30 days";
var lines = new []
{
"I will meet you in 30 days.",
"Payment terms are 7 days",
"I like 30 as a number",
"I am happy",
};
var results =
lines.Where(line =>search.Split(' ').All(word => line.Contains(word)));