发布:2022/12/6 17:38:53作者:管理员 来源:本站 浏览次数:698
/// <summary>}
/// <summary>
/// C# 实体对象Object转HashTable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <returns></returns>
public Hashtable Object2Hashtable(object obj)
{
Hashtable hash = new Hashtable();
PropertyInfo[]
ps =
obj.GetType().GetProperties(System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.Public);
foreach (PropertyInfo p in ps)
{
hash.Add(p.Name, p.GetValue(obj));
}
return hash;
}
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4