Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check whether the list contains item greater than a value in C# [closed]

I need to check that a List contains or not values that are greater that a specific value. How could I doing so?

like image 652
AyaZoghby Avatar asked Dec 20 '12 12:12

AyaZoghby


People also ask

How do you check if all elements in an array are greater than a value?

Using all() function we can check if all values are greater than any given value in a single line. It returns true if the given condition inside the all() function is true for all values, else it returns false.

How do you check whether a list contains a specified element?

Contains(T) Method is used to check whether an element is in the List<T> or not. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot.

How do you check if a list contains any value from another list?

To check if a list contains all elements of another list: Use a generator expression to iterate over the list. Check if each element in the first list is contained in the second list. The all() method will return True if the list contains all elements of the other list.

How do you check if an item is in a list in C?

To check if given Array contains a specified element in C programming, iterate over the elements of array, and during each iteration check if this element is equal to the element we are searching for.


1 Answers

Using LINQ:

bool contains = yourList.Any(z => z.YouProperty > yourValue);
like image 73
ken2k Avatar answered Sep 21 '22 17:09

ken2k