更新时间)2021年5月19日 仓库温控系统(Winform) 05 获取类属性静态方法PropertyHelper"/>
(更新时间)2021年5月19日 仓库温控系统(Winform) 05 获取类属性静态方法PropertyHelper
public class PropertyHelper
{/// <summary>/// 返回指定类型的指定列名的属性数组/// </summary>/// <typeparam name="T"></typeparam>/// <param name="cols"></param>/// <returns></returns>public static PropertyInfo[] GetTypeProperties<T>(string cols){Type type = typeof(T);//将列名字符串转换成List,转换成小写List<string> listCols = cols.GetStrList(',', true);//获取所有属性PropertyInfo[] properties = type.GetProperties();if (listCols != null && listCols.Count > 0){properties = properties.Where(p => listCols.Contains(p.GetColName().ToLower())).ToArray();}return properties;}
}
更多推荐
(更新时间)2021年5月19日 仓库温控系统(Winform) 05 获取类属性静态方法PropertyHelper
发布评论