Skip to content

Instantly share code, notes, and snippets.

@goloroden
Created December 16, 2011 12:59
Show Gist options
  • Save goloroden/1485958 to your computer and use it in GitHub Desktop.
Save goloroden/1485958 to your computer and use it in GitHub Desktop.
Combining Funcs
Func<User, bool> whereStatus = u => u.Status == status;
Func<User, bool> whereQuery =
u => u.Lastname.Contains(q) || u.Firstname.Contains(q) || u.UserId.Contains(q);
Func<User, bool> where = ...?
// What's requires: where = whereStatus && whereQuery
@forki
Copy link

forki commented Dec 16, 2011

Mhm I shouldn't have used generic parameters in a comment. They are all lost.

@forki
Copy link

forki commented Dec 16, 2011

Jon's solution is nice. Nevertheless tee implementation for my solution (you need to add the type parameters for the funcs) : return x => a(x) && b(x) ;

@forki
Copy link

forki commented Dec 18, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment