【发布时间】:2014-07-13 01:00:48
【问题描述】:
我有一个使用查询创建的 iQueryable 集合,如下所示 -
var Results = DataClass.Links.OrderBy(mySel => mySel.Description)
.Where(mySel => mySel.Report_Id.Equals(NumID)
new Sections
{
SectID = mySel.Report_Section.SectID,
SectionDesn = mySel.Report_Section.ReportSectionDescription,
ReportPageTitle = mySel.tbl_Report.ReportPageTitle,
MyUrl = mySel.Link_Url
}).Distinct();
我还有一个名为 LookForMe 的 List<string> 类型列表,定义为
var LookForMe = new List<string> { "increase", "abc", "tuesday", "another" };
我现在正在尝试遍历我的结果集合中的每个项目,如果 item.URL 包含在我的 LookForMe 列表中找到的值之一,如果是,那么做一些事情。
foreach (var item in Results)
{
if (item.URL *contains any of the values in my LookFormE list*)
{
// then do something
}
}
我不确定如何编写 if 语句来查找当前迭代值是否包含 LookForMe 列表中的任何值。有什么想法可以让我走上正轨吗?感谢您的宝贵时间。
【问题讨论】:
标签: c# linq list collections foreach