using System.Linq.Expressions;
public int StudentID { get; set; }
public string StudentName { get; set; }
public int Age { get; set; }
public static void Main()
var stud = new Student(){ StudentID = 1, StudentName = "Steve", Age = 20};
Func<Student, bool> isTeenager = s=> s.Age > 12 && s.Age < 20;
Console.WriteLine(isTeenager(stud));
Expression<Func<Student, bool>> isTeenExpr = s=> s.Age > 12 && s.Age < 20;
Console.WriteLine(isTeenExpr.Compile()(stud));