I have a C # class that has many virtual methods, some of these methods are essentially abstract (they are fully implemented in subclasses, and the base class is empty).
To get it for compilation, I throw an InvalidOperationException in the base class with a comment about what needs to be done. It just seems dirty.
Is there a better way to develop my classes?
edit: This is for a mid-tier application that will work in Canada, half of the methods are common, hence virtual. and half of the methods are province specific.
Public class PersonComponent()
{
public GetPersonById(Guid id) {
}
Public virtual DeletePerson(Guid id) {
}
Public virtual UpdatePerson(Person p) {
throw new InvalidOperation("I wanna be abstract");
}
Public Class ABPersonComponent : PersonComponent
{
public override DeletePerson(Guid id)
{
}
public override UpdatePerson(Person p)
{
}
}
hope it makes sense
source
share