You need to get the PropertyInfo
associated with the property (e.g. via typeof(Class1).GetProperty("Name")
) and then call GetCustomAttributes
.
It's a bit messy due to returning multiple values - you may well want to write a helper method to do this if you need it from a few places. (There may already be a helper method in the framework somewhere, but if there is I'm unaware of it.)
EDIT: As leppie pointed out, there is such a method: Attribute.GetCustomAttribute(MemberInfo, Type)