I have an abstract base class:
public abstract class BaseObject
{
internal abstract string DatabaseTableName { get; }
internal abstract string ObjectType { get; }
// other class members not important
}
That has two abstract subclasses -- the only difference is one has a 32-bit Id and the other a 64-bit Id:
public abstract class BaseObject32 : BaseObject
{
public int Id { get; private set; }
// other class members not important
}
public abstract class BaseObject64 : BaseObject
{
public long Id { get; private set; }
// other class members not important
}
I would like to make it so that any class that inherits BaseObject32 or BaseObject64 must implement these two properties, but then those properties should be accessible via the BaseObject class.
In other words, I'd like to do this:
public class Cat : BaseObject32
{
DataBaseTableName => "animals.cat";
ObjectName => "Cat";
}
And then be able to do this:
BaseObject c = new Cat();
string x = c.DatabaseTableName;
I'm clearly missing something. I've tried addding "new" and "override" within my Cat class, but it keeps saying I need to implement the inherited class member. Here is a rough idea of what I want in each inheriting class.
private const string _ObjectType = "Cat";
private const string _DataBaseTableName = "animals.cat";
internal override string ObjectType => _ObjectType;
internal override string DatabaseTableName => _DataBaseTableName;
I am hopeful this is possible and I'm just missing something...