结论:默认情况遍历属性时,是不会遍历到静态成员的。
测试代码:
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; }
}
}