RoyalBlue

PhysiqueOutModel physiqueOutModel = new PhysiqueOutModel ();//自定义对象

Type t = physiqueOutModel.GetType();//获得该类的Type

foreach (PropertyInfo pi in t.GetProperties())
{
  string name = pi.Name;//获得属性的名字,后面就可以根据名字判断来进行些自己想要的操作

  var value = pi.GetValue(physiqueOutModel, null);//用pi.GetValue获得值

       string newVal = "新值";

      pi.SetValue(physiqueOutModel, newVal);//设置属性值

}

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
  • 2021-10-20
相关资源
相似解决方案