c# - Lambda 检查列表是否包含所有属性的某些属性值

标签 c# asp.net linq lambda

在主题中很难解释,但我如何知道所有列表 x.someprop 是否与值 7 匹配?换句话说,如果下面的过滤器返回整个列表:

myList.Where( x => x.someprop == 7).ToList();

最佳答案

使用Enumerable.All

bool result = myList.All( x => x.someprop == 7);

关于c# - Lambda 检查列表是否包含所有属性的某些属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13607042/

相关文章:

c# - Response.OutputStream.Write 中的 "The remote host closed the connection"

c# - 我的 JavaScript 有什么问题吗? (C#/ASP.NET)

c# - 通过示例将空值添加到 IEnumerable 作为第一记录的最佳方法

c# - LINQ 组求和查询中的 Bool 到 int

linq - 域模型 + LINQ to SQL 示例

c# - C# 字典的原子 AddOrUpdate

c# - BlockingCollection with Parallel.For 挂起?

c# - 将 JSON 批量导入到 Azure Cosmos DB 时引发异常 : 'Microsoft.Azure.Cosmos.CosmosException' , 错误请求

c# - 如何在 asp.net 中发回 JSON?

asp.net - 如何防止托管在 Azure 上的开发暂存网站被搜索引擎索引