object[] data = new string[3];data[0] = "s";data[0] = 1; //no compiler error- just a runtime ArrayTypeMismatchException
IList<Cat> cats = new List<Cat>();//you can cast to IEnumerable (or IQueryable)IEnumerable<Animal> pets = cats;//but you cannot cast to the read-write classes//IList<Animal> animals = cats; //compiler error
var cats = new List<Cat>(); //predicate is contravariant cats.Find(HasFur); //private static bool HasFur(Animal animal) //so is IComparable cats.Sort(SortByName); //private static int SortByName(Animal x, Animal y)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.