Property as an Argument
using System;
using System.Linq.Expressions;
using System.Reflection;
void DoSomething<T>(Expression<Func<T>> property)
{
// Get info
PropertyInfo propertyInfo = ((MemberExpression)property.Body).Member as PropertyInfo;
// Get name
string name = propertyInfo.Name;
// Get value
T pValue = property.Compile()();
// Do something with the variables we've filled.
}
Used like
DoSomething(() => AProperty);