天天看点

C#反射操作Type类去掉父类的属性

Type type = t.GetType();
type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public)//不要父类的
//也可以这么写,去掉父类的Id
type.GetProperties.Where(p=>!p.Name.Equals("Id"));