namespace Generics;

public class Base
{
    public static void UseBase(Base b)
    {
    }

    public static void AllYourBase(IEnumerable<Base> bases)
    {
    }

    public static void PassingIEnumerable()
    {
        IEnumerable<Derived> derivedItems = new[] { new Derived(), new Derived() };
        AllYourBase(derivedItems);
    }

    public static void AddBase(ICollection<Base> bases)
    {
        bases.Add(new Base());
    }

    // Zmień na #if true by zobaczyć błąd kompilatora
#if false
        public void IllegalAddBase()
        {
            ICollection<Derived> derivedList = new List<Derived>();
            AddBase(derivedList);  // tego nie uda się skompilować!
        }
#endif

    public static void UseBaseArray(Base[] bases)
    {
        bases[0] = new Base();
    }

    public static void PassDerivedElementTypeArray()
    {
        Derived[] derivedBases = { new Derived(), new Derived() };
        UseBaseArray(derivedBases);
    }
}
