c# - Inherited auto-implemented property with private setter -


i have base class , derived class. each has same property has private setter value can set logic inside class.

class first {     internal virtual int value { get; private set; }      void setvalue(int tovalue)     {         value = tovalue;     } }  class second : first {     internal override int value { get; private set; }      void setvalue(int tovalue)     {         value = tovalue;     } } 

this resulting in compiler error:

the property or indexer ... cannot used in context because set accessor inaccessible.

why case, , how can achieve i'm trying do? not possible auto-implemented properties, in other words, have use backing field instead?

second unable set value of value first due values setter being private. if need subclass able set it, needs protected in base.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -