public static string GetObjectPropertyValue<T>(T t, string propertyname){ Type type = typeof(T); PropertyInfo property = type.GetProperty(propertyname); if (property == null) return string.Empty; object o = property.GetValue(t, null); if (o == n
Service1.java package reflection; public class Service1 { public void doService1(){ System.out.println("业务方法1"); } } Service2.java package reflection; public class Service2 { public void doService2(){ System.out.println("业务方法1"); } } s
获取所有字段的值: public void PrintProperties(Object obj) { Type type = obj.GetType(); foreach( PropertyInfo p in type.GetProperties()) { Console.Write(p.GetValue()); } }