C# 反射公共属性
/// <summary> /// 获取某个类型中属性列表 ///</summary> /// <param name="type"></param> /// <param name="withOuts">排除特性,如果属性含有此特性,则不获取</param> /// <returns></returns> public static List<PropertyInfo> GetPublicProperties(this Type type, params Attribute[] withOuts) { return type.GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(q => !q.IsSpecialName && !q.GetCustomAttributes().Any(withOuts.Contains)).ToList(); }