嗨,我想从包含例如“30 天”的集合中找到一个项目。我想先搜索“30”,然后再搜索“天”。我应该如何使用 lambda 表达式来做到这一点?有人可以给我一个例子吗?
谢谢
string search = "30 days";
var result = MyEnumerable.Where(x=>search.Split(' ').Contains(x.fieldToSearch))
尝试这个:
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)));