prolist p1 = new prolist();
List<String> lt = getattr<prolist>(p1);
//使用泛型,返回传入对象的属性,名称
public List<String> getattr<T>( T dx )
{
List<String> ls = new List<String>();
Type types = dx.GetType();
foreach (var p in types.GetProperties())
{
// p.PropertyType
ls.Add(p.Name);
}
return ls;
}
}
//实体对象
public class prolist
{
private string _pid = "0";
private string _pmoney = "0";
public string pid
{
set { this._pid = value; }
get { return this._pid; }
}
public string pmoney
{
set { this._pmoney = value; }
get { return this._pmoney; }
}
}
时间: 2024-10-05 04:56:39