Base on This Answer, I can get description attribute from class Property
as follow:
public class A
{
[Description("My Property")]
public string MyProperty { get; set; }
}
I can get Description
value, as follow:
// result: My Property
var foo = AttributeHelper.GetPropertyAttributeValue<A, string, DescriptionAttribute, string>(x => x.MyProperty, y => y.Description);
and now, I want use this helper to get description from cosnt
fields
as follow:
public class A
{
[Description("Const Field")]
public const string ConstField = "My Const";
}
Aucun commentaire:
Enregistrer un commentaire