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

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -