Sign in | Join
Last post 07-03-2009 7:38 AM by FoolongC. 2 replies.
Sort Posts: Oldest to newest Newest to oldest
Hi all,
Can anyone post an example of reflecting on an object and if I find a property in that object then setting that property's value and then returning the object.
I want to create a method that takes an object and a string that represents the property I want to set.
Thanks in advance.
Your code will look something like this:
PropertyInfo pinfo = typeof(YourClass).GetProperty(key); MethodInfo setInfo = pinfo.GetSetMethod(true); if (setInfo != null) setInfo.Invoke(null, param);
This is what I'm looking for and will work. Thank you!