我需要检查一个列表中是否包含大于特定值的数值。我该如何做到呢?
使用 LINQ:
bool contains = yourList.Any(z => z.YouProperty > yourValue);
Enumerable.Any<TSource>
方法。它返回一个 boolean
类型。
确定序列是否包含任何元素。
Return Value
Type: System.Boolean
true if the source sequence contains any elements; otherwise, false.
List.Any(a => a.Property > Value);