Which code should you use?

You have the following code:

You need to retrieve all of the numbers from the items variable that are greater than 80.
Which code should you use?

You have the following code:

You need to retrieve all of the numbers from the items variable that are greater than 80.
Which code should you use?

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
Enumerable.Where<TSource> Method (IEnumerable<TSource>, Func<TSource, Boolean>)
Filters a sequence of values based on a predicate.
Example:
List<string> fruits =
new List<string> { “apple”, “passionfruit”, “banana”, “mango”,
“orange”, “blueberry”, “grape”, “strawberry” };
IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 6);
foreach (string fruit in query)
{
Console.WriteLine(fruit);
}
/*
This code produces the following output:
apple
mango
grape
*/



Leave a Reply 0

Your email address will not be published. Required fields are marked *