I am updating a loooong... list of properties of an object. I was wondering if there was a way to pass the propertyName as a parameter.
So that, after I checked that the property exists in the object (that I know how to do) - I could just write UpdateObject(ObjectName, propertyName, NewValue).
As you can tell, I'm at the bottom of the learning curve in C#. I have already looked up "similar questions" regarding this issue in SO, without success, at least that I could understand...
If you could point me in the right direction, that would be very kind.
Anyhow, I'll have to thank this fine community of SO'contributors, because over the years I've gotten many, many hints and answers from your posts.
Actually, I followed your advice and went with :
Type type = target.GetType();
PropertyInfo prop = type.GetProperty("propertyName");
prop.SetValue (target, propertyValue, null);
// where target is the object that will have its property set.
Thanks to all