I was curious if it was possible to create like a parent abstract class that I can define a specific set of methods in but have the children classes include different entity types? Code Example:
public abstract class BaseService
{
public abstract void Add();
public abstract void Delete();
public abstract void Update();
public abstract void Get();
}
Maybe be able to do something like public abstract List<'random type'> GetAll();
But here i would want to override each method with specific parameters that are specific to each of its children:
public class CategoryService : BaseService
{
public override void Add(){ }
public override void Delete(){ }
public override void Update(){ }
public override void Get(){ }
}
However, in my child class, I would want my Get() method to return a specific List<"of Type"> (in this case Category). Furthermore, I might want to do public override Add(int CategoryID)
instead of the inherited Add
from BaseService
.
Is this possible? Thoughts? Am I just crazy? Or am I trying to make this more complicated than it needs to be? I have about 10 different service types that I want to make sure get those generic methods from BaseService
.
Thanks in advance!