結論:反射 獲取類的所有屬性,默認情況,是不會遍歷到靜態成員的。
測試代碼:
public class Class11
{
public void test1()
{
c1 model = new c1();
model.name = "name1";
Type t = model.GetType();
PropertyInfo[] pArray = t.GetProperties();
Array.ForEach<PropertyInfo>(pArray, p =>
{
Console.WriteLine(p.Name);
});
}
public class c1
{
public static string StrIds = "12333";//這個字段 反射時不會遍歷到
public string name { get; set; }
}
}