I got a warning message from ReSharper that "virtual member call in constructor" on Classification = new T();
:
public abstract class Creature<T> where T : new() {
protected Creature()
{
Classification = new T();
}
public abstract T Classification { get; protected set; }
}
public class Dog : Creature<Animal>
{
public override Animal Classification { get; protected set; }
}
public class Animal{
public void AnimalSpecificMethod() { }
}
How can I solve this prolbem? Maybe an idea to re-design this structure?
What I would like to achieve is to create the same class type in Dog class what contains the Classification as it has declared through the Creature class.
Thank you!