propertyinfo

Reflection - get attribute name and value on property

别等时光非礼了梦想. 提交于 2019-11-26 01:22:17
问题 I have a class, lets call it Book with a property called Name. With that property, I have an attribute associated with it. public class Book { [Author(\"AuthorName\")] public string Name { get; private set; } } In my main method, I\'m using reflection and wish to get key value pair of each attribute for each property. So in this example, I\'d expect to see \"Author\" for attribute name and \"AuthorName\" for the attribute value. Question: How do I get the attribute name and value on my