Mega Code Archive

 
Categories / C# / Reflection
 

Gets the attributes for this property

using System; using System.Reflection; public class Myproperty {     private string caption = "Default caption";     public string Caption     {         get{return caption;}         set {if(caption!=value) {caption = value;}         }     } } class MainClass {     public static int Main(string[] args)     {         Myproperty Myproperty = new Myproperty();         Console.Write(Myproperty.Caption);         Type MyType = Type.GetType("Myproperty");         PropertyInfo Mypropertyinfo = MyType.GetProperty("Caption");         PropertyAttributes Myattributes = Mypropertyinfo.Attributes;         Console.Write(Myattributes.ToString());         return 0;     } }