using System.Collections.Generic;
public interface IElement
public class AElement : IElement
public void DoSomethingSpecial()
public class Container<TElement>
public List<TElement> Elements { get; } = new();
public static Container<IElement> GetContainer()
var concreteContainer = new Container<AElement>();
concreteContainer.Elements.ForEach(e => e.DoSomethingSpecial());
return concreteContainer;
public static void Main()
var myContainer = GetContainer();