It appears that I need to pass an Expression Tree to a method to be able to get its name, but i also want to set the value also, is there a way to do that:
name = Method(() => property, value);
public string Method<T>(Expression<Func<T>> property, T value)
{
var propertyName = GetPropertyString(property);
return propertyName;
}
Thanks
Note: The solutions using reflection would work well, except that the method is in the base class and the properties are in a derived class, so that would have to pass the a reference to the derived class in order for solution to work. I was hopeing there was some way to use the property information to set the value. It would be just as clean to send the property reference in the Expression Tree information. Anybody understand expresson trees well enough?