比如我现在有一个Student的对象,里面有属性stuName,stuAge,stuGender,我现在该怎么写循环才能遍历这几个属性?

 

 

Student s=new......
foreach (System.Reflection.PropertyInfo p in s.GetType().GetProperties())
{
Console.WriteLine("Name:{0} Value:{1}", p.Name, p.GetValue(s));
}



转载至左正

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-26
  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2021-09-22
相关资源
相似解决方案