2 using System
.Collections
.Generic
;
4 using System
.Linq
.Expressions
;
8 public int Age { get; set; }
15 var persons
= GetPersons (new [] { new Person { Age = 25 }
, new Person { Age = 21 }
}, 25);
16 return persons
.Count () - 1;
19 static IEnumerable
<T
> GetPersons
<T
> (IEnumerable
<T
> persons
, int age
) where T
: Person
21 foreach (var person
in persons
)
22 if (Test (person
, p
=> p
.Age
== age
))
26 static bool Test
<T
> (T t
, Expression
<Func
<T
, bool>> predicate
)
28 return predicate
.Compile () (t
);