C# variance problem: Assigning List as List

Well this certainly won’t be supported in C# 4. There’s a fundamental problem: List<Giraffe> giraffes = new List<Giraffe>(); giraffes.Add(new Giraffe()); List<Animal> animals = giraffes; animals.Add(new Lion()); // Aargh! Keep giraffes safe: just say no to unsafe variance. The array version works because arrays do support reference type variance, with execution time checking. The point of … Read more