Mega Code Archive

 
Categories / C# / Reflection
 

Gets a value indicating whether the property can be written to

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.Write("\nMypropertya.Caption = " + Mypropertya.Caption);         Mypropertya.Caption = "A- No Change";         Console.Write("\nMypropertya.Caption = " + Mypropertya.Caption);         Type MyTypea = Type.GetType("Mypropertya");         PropertyInfo Mypropertyinfoa = MyTypea.GetProperty("Caption");         Console.Write("\nCanWrite a - " + Mypropertyinfoa.CanWrite);         return 0;     } }