private Hashtable ConvertDto2Ht()
{
Hashtable _ht = new Hashtable();
PropertyInfo[] propertyInfos = dto.GetType().GetProperties();
foreach (PropertyInfo item in propertyInfos)
{
_ht.Add(item.Name, item.GetValue(dto, null));
}
return _ht;
}
{
Hashtable _ht = new Hashtable();
PropertyInfo[] propertyInfos = dto.GetType().GetProperties();
foreach (PropertyInfo item in propertyInfos)
{
_ht.Add(item.Name, item.GetValue(dto, null));
}
return _ht;
}
本文介绍了一种将DTO对象的属性转换为Hashtable的方法实现。通过反射获取DTO的所有属性,并将其名称与值添加到Hashtable中,便于进行后续的数据处理。
915

被折叠的 条评论
为什么被折叠?



