public static void Main()
var compositeFilter = GetLetterFilter().And(GetLengthFilter(), GetSpaceFilter());
var source = new[]{"", "Alabama", "", "Wachinton DC"};
var matches = source.AsEnumerable().Where(compositeFilter);
Console.WriteLine(string.Join(", ", matches));
public static Func<string, bool> GetLetterFilter()
return x => x.Contains("a");
public static Func<string, bool> GetLengthFilter()
return x => x.Length > 5;
public static Func<string, bool> GetSpaceFilter()
return x => x.Contains(" ");
public static class FuncExtensions
public static Func<T, bool> And<T>(this Func<T, bool> arg0, Func<T, bool> arg1)
return x => arg0(x) && arg1(x);
public static Func<T, bool> And<T>(this Func<T, bool> arg0, Func<T, bool> arg1, Func<T, bool> arg2)
return x => arg0(x) && arg1(x) && arg2(x);
public static Func<T, bool> And<T>(this Func<T, bool> arg0, Func<T, bool> arg1, Func<T, bool> arg2, Func<T, bool> arg3)
return x => arg0(x) && arg1(x) && arg2(x) && arg3(x);