using System.Linq.Expressions;
using System.Collections.Generic;
public static void Main()
Person f1 = new Person("Bob", "1");
Person f2 = new Person("Joe", "2");
Person f3 = new Person("Sue", "3");
List<Person> PersonList = new List<Person>{f1, f2, f3};
Func<List<Person>, string, string, bool> deleg =
Console.WriteLine("Searching for {0} : {1}", prop, val);
foreach (Person obj in objL)
string oType = obj.GetType().Name;
PropertyInfo pType = obj.GetType().GetProperty(prop);
string pName = obj.GetType().GetProperty(prop).ToString();
var pVal = pType.GetValue(obj);
PropertyInfo N = obj.GetType().GetProperty("Name");
var nVal = N.GetValue(obj);
Console.WriteLine("Name : " + nVal);
Console.WriteLine("{0} : {1}", prop, val);
bool result = deleg(PersonList, "id", "2");
Console.WriteLine(result);
public string Name {get; set;}
public string id {get; set;}
public string Fullname {get;}
public Person(string name, string id)
this.Fullname = name + " " + id;
Console.WriteLine(this.Fullname);