I don't know what pattern I have to implement for forcing the derived class to override the method Print
returning only its class name.
class Base
{
protected virtual string Print() => nameof(Base);
static void Main(string[] args)
{
Base b = new Derived();
Console.WriteLine(b.Print());
}
}
class Derived : Base
{
protected override string Print() => nameof(Derived);
}
Aucun commentaire:
Enregistrer un commentaire