Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / tests / gtest-etree-14.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Linq.Expressions;
5
6 class Person
7 {
8         public int Age { get; set; }
9 }
10
11 class Repro
12 {
13         public static int Main ()
14         {
15                 var persons = GetPersons (new [] { new Person { Age = 25 }, new Person { Age = 21 } }, 25);
16                 return persons.Count () - 1;
17         }
18
19         static IEnumerable<T> GetPersons<T> (IEnumerable<T> persons, int age) where T : Person
20         {
21                 foreach (var person in persons)
22                         if (Test (person, p => p.Age == age))
23                                 yield return person;
24         }
25
26         static bool Test<T> (T t, Expression<Func<T, bool>> predicate)
27         {
28                 return predicate.Compile () (t);
29         }
30 }