I have Person.cs which will be implemented by, for example, the Player class.
Person has an ExperienceLevelType property.
I want to force all classes that derived from Person to implement their own version of the ExperienceLevelType property.
public abstract Person
{
public enum ExperienceLevel { Kid, Teenager}
public virtual ExperienceLevel Experience {get; set;}
}
public abstract Player:Person
{
public override ExperienceLevel Experience
{
}
}
That’s what
abstractis for:If you want to force derived classes to implement the property themselves while at the same time providing some reusable scaffolding to help them, expose the scaffolding as
protectedmembers insidePerson.