Mega Code Archive

 
Categories / C# / Reflection
 

Returns an array whose elements reflect the public, non-public get, set, and other accessors

using System; using System.Reflection; public class Myproperty    {     private string caption = "A Default caption";     public string Caption     {         get{return caption;}         set {if(caption!=value) {caption = value;}         }     } } class Mypropertyinfo {     public static int Main()     {         Type MyType = Type.GetType("Myproperty");         PropertyInfo Mypropertyinfo = MyType.GetProperty("Caption");         MethodInfo[] Mymethodinfoarray = Mypropertyinfo.GetAccessors(true);         Console.Write ( Mymethodinfoarray.Length + " accessors (public).");         return 0;     } }