Èç public class A { public int Pro1 { get; set; } public int Pro2 { get; set; } }
A a = new A(); ÈçºÎ»ñÈ¡a.Pro1µÄ×Ö·û´®Ãû³Æ¡£¼´ÈçºÎ»ñµÃ"Pro1"ÉùÃ÷ÌØÐÔ,msdnÉϲéһϠC# code:
using System.Reflection;
Type t = typeof(A); foreach(PropertyInfo pi in t.GetProperties(BindingFlags.Instance | BidngFlags.Public)) { Console.WriteLine(pi.Name); }
Õý½â ·´Éä, System.Reflection.PropertyInfo[] propertys =¶ÔÏñ.GetType().GetProperties(); foreach (System.Reflection.PropertyInfo info in propertys) { //info.Name ÊôÐÔÃû³Æ } void Test() { A a