Mega Code Archive

 
Categories / C# / Reflection
 

Gets a value indicating whether the property can be read

using System; using System.Reflection; public class Mypropertya {     private string caption = "A Default caption";     public string Caption     {         get{return caption;}         set {if(caption!=value) {caption = value;}         }     } } class MainClass {     public static int Main()     {         Mypropertya Mypropertya = new Mypropertya();         Console.WriteLine(Mypropertya.Caption);         Type MyTypea = Type.GetType("Mypropertya");         PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Caption");         Console.WriteLine(Mypropertyinfoa.CanRead);         return 0;     } }