import java.beans.PropertyDescriptor; import java.lang.reflect.Field; import java.lang.reflect.Method; public class BeanChangeUtil<T> { public static <T> void main(String[] args) { User u1 = new User("1", true, "a"); User u…
package com.lanqiao.demo; /** * 创建人 * @author qichunlin * */ public class Person { private int id; private String name; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void…
Field[] field = behavior.getClass().getDeclaredFields(); for (int i = 0; i < field.length; i++) { String name = field[i].getName(); name = name.substring(0, 1).toUpperCase() + name.substring(1);//找到首位改成大写形式 String type = field[i].getGenericType().toS…
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…