比如有一个类:
public class Product
{
private int mID;
public int ID{get{return this.mID}set{this.mID=value;}}
}那么我如何利用放射设置PRODUCT类的数值呢?public TType GetProduct(int pID)
{
TType ret = default(TType);
// 如何通过TType的属性设置数值呢?
return ret;}
public class Product
{
private int mID;
public int ID{get{return this.mID}set{this.mID=value;}}
}那么我如何利用放射设置PRODUCT类的数值呢?public TType GetProduct(int pID)
{
TType ret = default(TType);
// 如何通过TType的属性设置数值呢?
return ret;}
public Type GetProduct(int pID)
{
Type ret = typeof(Product);
PropertyInfo pr= ret.GetProperty("ID");
pr.SetValue(p, pID, null); //赋值属性
return ret; }
CSDN自动回帖机--AutoBack
p m51.com/bbs/dispbbs.asp?boardid=8&Id=67 呵呵,,,,