C# Get attribute info

Date: 2019-09-17
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);
}

25850cookie-checkC# Get attribute info