You can always use something like
object myObject = new object();
System.Reflection.PropertyInfo pi = myObject.GetType().GetProperty(
"targetPropertyName",
System.Reflection.BindingFlags.CreateInstance
| System.Reflection.BindingFlags.NonPublic
);
pi.GetValue(myObject, null);
GetValue()
returns an
Object
so you have to know what to cast it to.
There is a
SetValue()
, too.
In general, this reflection stuff is believed to be slow and error-prone. So use it at your own risk. Usually private properties are private for a reason.