Assigning a value to an inherited readonly field?

So I have a base class that has many children. This base class defines some readonly properties and variables that have default values. These can be different, depending on the child.

Readonly properties/fields allow you to change the value of the variable inside the constructor and also the definition, but nowhere else. I get a 'readonly variable can only be assigned to in a constructor' error if I try to change the value of an inherited readonly variable in the child class' constructor. Why is this and how can I work around this, without Reflection?

My intention: To allow user extensibility through scripts where they can only change certain fields once.

25
задан Steffan Donal 18 May 2011 в 05:45
поделиться