Consider the following code:
string propertyName;
var dateList = new List() { DateTime.Now };
propertyName = dateList.GetPropertyName(dateTimeObj
Something like this should do the trick:
public static string GetPropertyName(this IList list, Expression> expr) {
MemberExpression member_expression = expr.Body as MemberExpression;
if (member_expression == null)
throw new ArgumentNullException("member_expression");
MemberInfo member = member_expression.Member;
PropertyInfo property = member as PropertyInfo;
string proname = memeber.name;
}
WARNING: Air Code!