我有一個類如下:找到所有關鍵字
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那樣。我無法控制它。 –