我有一个类如下:找到所有关键字
public class PropertyResult {
public Int32 Id { get; set; }
public String Keywords { get; set; }
}
我有这个类的一个列表和一个字符串:
List<PropertyResult> properties = externalAPI.GetProperties();
List<String> keywords = new List<String> { "A", "B", "C" }
注意,属性的关键词是类似“A, B,C“。
我需要获取所有包含所有关键字的属性。我正在为:
properties = listing.Properties.All(x => keywords.Contains(x.Keywords))
问题是,x.Keywords在字符串中包含所有关键字。
你可以改变'Keywords'是一个'List'而不是逗号分隔字符串? –
不......这就像来自外部API那样。我无法控制它。 –