【发布时间】:2019-11-14 19:42:24
【问题描述】:
我有一组搜索词和一个集合。我需要测试该句子是否包含所有搜索词:
var searchTerms = "fox jumped".Split(' ');
var sentence = "the quick brown fox jumped over the lazy dog".Split(' ');
var test = sentence.Contains(searchTerms);
我预计 test 是 True ——但是我得到了一个编译错误: 'string[]' 不包含 'Contains' 的定义,并且最佳扩展方法重载 'System.Linq.Queryable.Contains(System.Linq.IQueryable, TSource)' 有一些无效参数
我应该如何测试该句子是否包含所有搜索词?
【问题讨论】: