标签:line name bsp new 一个 property reflect class nbsp
比如我现在有一个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));
}
转载至左正
标签:line name bsp new 一个 property reflect class nbsp
原文地址:http://www.cnblogs.com/big-lll/p/7641846.html