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 value
s setter being private
. if need subclass able set it, needs protected
in base.
Comments
Post a Comment