m.pen = Pens.Red; //No error
m.pen.EndCap = System.Drawing.Drawing2D.LineCap.Square; //error
Where m is an object of another class which holding the Pen as global.
While i am trying to set endcap or startcap it shows me the error as
“Changes cannot be made to Pen because permissions are not valid.”
Anyone Know How to Rectify This.
Pen object returned by Pens are immutable, meaning their properties cannot be changed. Try creating an object of Pen.