Type t = typeof("your class name");propertyInfo[] myproperties=t.GetProperties;
Type type = o1.GetType(); PropertyInfo pi = type.GetProperty(f); object obj = pi.GetValue(o1, null);
如果abc是private 的,需要设置Flag才能拿到~~~~~
using System.Reflection;
object o = ...;
Console.WriteLine(o.GetType().Name);
foreach (PropertyInfo pi in o.GetType().GetProperties(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance)) { object v = pi.GetValue(o,null); Console.WriteLine("{0}={1}", pi.Name, v);
PropertyInfo pi = type.GetProperty(f);
object obj = pi.GetValue(o1, null);
object o = ...;
Console.WriteLine(o.GetType().Name);
foreach (PropertyInfo pi in o.GetType().GetProperties(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance))
{
object v = pi.GetValue(o,null);
Console.WriteLine("{0}={1}", pi.Name, v);
}