Passing in func via where clause

Go To StackoverFlow.com

2

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

2012-04-05 16:31
by dotnetdev


5

Do you mean something like this?

public IEnumerable<string> FilterNames(Func<string, bool> filter)
{
    return people.Select(person => person.Name)
                 .Where(filter);
}
2012-04-05 16:32
by Jon Skeet
very simple but that was it - dotnetdev 2012-04-05 17:45
Ads