I am using the following code to pass a property to a lambda expression.
namespace FuncTest
{
class Test
{
public string Name { get; set; }
}
class Program
{
static void Main(string[] args)
{
Test t = new Test();
t.Name = "My Test";
PrintPropValue(t => t.Name);
}
private static void PrintPropValue(Func<string> func)
{
Console.WriteLine(func.Invoke());
}
}
}
This does not compile. I just want the function to be able to take property and be able to evaluate.