I have a base class, FooBase. On it are a few standard read/write properties. When i subclass this, i want the subclass to have only read properties. Is this possible?
class FooBase
{
public virtual int ID{get; set;}
public virtual string Name{get;set;}
}
class Foo : FooBase
{
public override int ID {get;}
public override string Name{get;}
}
I know that code doesnt work, but it might give you some idea what im after
Thanks!
No. You have your class heirarchy the wrong way round.
The writable version should be a subclass of the readonly version. Here’s one way you could do it: