2010-02-20 Zoltan Varga <vargaz@gmail.com>
[mcs.git] / tests / gtest-etree-14.cs
blob79d474ded04d69206b3d31250fab34f2ba4ce90e
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Linq.Expressions;
6 class Person
8 public int Age { get; set; }
11 class Repro
13 static int Main ()
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))
23 yield return person;
26 static bool Test<T> (T t, Expression<Func<T, bool>> predicate)
28 return predicate.Compile () (t);