6
Answers

Enumerable.Where method

S

S

12y
1.6k
1
Hi

Given the following code

List<string> fruits = new List<string>
{ "apple", "passionfruit", "banana", "mango", "orange", "blueberry", "grape", "strawberry"};

IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 6);



Im having difficulty in matching this up to the actual Where method declaration as below:-


public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source,Func<TSource, bool> predicate

From what I can work out so far:-

IEnumerable<TSource> is IEnumerable<string> and the Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, is the (fruit => fruit.Length < 6); Linq & Lambda part?


Regards

Steven

Answers (6)