c# - make description for a property -
how can make description property , receive via system.reflection ?
you use custom attribute:
public class fooattribute : attribute { public string description { get; set; } } public class bar { [foo(description = "some description")] public string barproperty { get; set; } } public class program { static void main(string[] args) { var foos = (fooattribute[])typeof(bar) .getproperty("barproperty") .getcustomattributes(typeof(fooattribute), true); console.writeline(foos[0].description); } }
Comments
Post a Comment