GurdeepS
GurdeepS

Reputation: 67223

Passing in func via where clause

Given a .net 4. collection, if I want to pass in my own custom func in a where clause, how could I do this (via parameters)?

Thanks

Upvotes: 2

Views: 701

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500495

Do you mean something like this?

public IEnumerable<string> FilterNames(Func<string, bool> filter)
{
    return people.Select(person => person.Name)
                 .Where(filter);
}

Upvotes: 6

Related Questions