private static T1 GetAttribute<T1>(global::System.Reflection.PropertyInfo prop) where T1 : Attribute { return prop.GetCustomAttributes(typeof(T1), false).FirstOrDefault() as T1; } var properties = typeof(T).GetProperties(); foreach (var prop in properties) { var requiredAttr = GetAttribute<RequiredAttribute>(prop); }
258500cookie-checkC# Get attribute info