我有一个类 Person 有两个属性
public sealed class Person
{
[Description("This is the first name")]
public string FirstName { get; set; }
[Description("This is the last name")]
public string LastName { get; set; }
}
在我的控制台应用程序代码中,我想为每个实例的每个属性获取描述属性的值.....
类似于
Person myPerson = new Person();
myPerson.LastName.GetDescription() // method to retrieve the value of the attribute
有可能完成这个任务吗?有人可以建议我一个方法吗?最好的问候 Fab