Override only Get accessor

c#

Solution

If at first you have defined a read-only property in a type, you can't later change it to a read/write property in a derived class. That's simply how .NET works, and can't be changed.

If, on the other hand, you define an interface with a read-only property, you can later implement that interface in a class with a writable property.

If you'd like to share what you are trying to achieve, perhaps we can come up with a design that works and can compile :)

Problem

I got an abstract class : ``` abstract class ClassBase { public abstract string Test { get; } } ``` I want to derive it and by the way add a set accesor ``` class ClassDerive : ClassBase { string _s; public override string Test { get { return _s; } set { _s = value; } } } ``` I can't do that because i may not override set ``` class ClassDerive2 : ClassBase { string _s; public string Test { override get { return _s; } set { _s = value; } } } ``` Syntax error ``` class ClassDerive3 : ClassBase { string _s; public override string ClassBase.Test { get { return _s; } } public string Test { set { _s = value; } } } ``` Syntax error Any Idea ??? thx

Original source