.NET Fiddle

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
            // Works as Expected
            var trainer = new Trainer(new Dog());
            Console.WriteLine(trainer.Train());

            // Works as Expected
            var dogTrainer = new DogTrainer(new Dog());
            Console.WriteLine(dogTrainer.Train());

            // Does not work as expected
            // Calls the Trainer Train not the Dog Trainer Train
            var getTrainer = new Func<Trainer>(() => new DogTrainer(new Dog()));
            var funcTrainer = getTrainer();
            Console.WriteLine(funcTrainer.Train());

            // Works as expected 
            var getITrainer = new Func<ITrainer>(() => new DogTrainer(new Dog()));
            var funcITrainer = getITrainer();
            Console.WriteLine(funcITrainer.Train());

            // Does not work as expected 
            // Calls the Trainer Train not the Dog Trainer Train
            var getTrainerWithNoInterface = new Func<Trainer>(() => new DogTrainerWithNoInterface(new Dog()));
            var funcTrainerWithNoInterface = getTrainerWithNoInterface();
            Console.WriteLine(funcTrainerWithNoInterface.Train());

            // Does not work as expected 
            // Calls the Trainer Train not the Dog Trainer Train
            var getITrainerWithNoInterface = new Func<ITrainer>(() => new DogTrainerWithNoInterface(new Dog()));
            var funcITrainerWithNoInterface = getITrainerWithNoInterface();
            Console.WriteLine(funcITrainerWithNoInterface.Train());
	}
	
    public class DogTrainer : Trainer, ITrainer
    {
        public DogTrainer(IAnimal animal)
            : base(animal)
        { }

        public new string Train()
        {
            return $"Speak Ubu, Speak : {Animal.Speak()}";
        }
    }

    public class DogTrainerWithNoInterface : Trainer
    {
        public DogTrainerWithNoInterface(IAnimal animal)
            : base(animal)
        { }

        public new string Train()
        {
            return $"Speak Ubu, Speak : {Animal.Speak()}";
        }
    }

    public class Trainer : ITrainer
    {
        internal readonly IAnimal Animal;

        public Trainer(IAnimal animal)
        {
            Animal = animal;
        }

        public string Train()
        {
            return Animal.Speak();
        }
    }

    public interface ITrainer
    {
        string Train();
    }

    public class Dog : IAnimal
    {
        public string Speak()
        {
            return "Woof";
        }
    }

    public interface IAnimal
    {
        string Speak();
    }	
}
;