IDictionary in .NET 4 not covariant

It’s a feature. .NET 4.0 only supports safe covariance. The cast you mentioned is potentially dangerous as you could add a non-string element to the dictionary if that was possible: IDictionary<string, object> myDict = new Dictionary<string, string>(); myDict[“hello”] = 5; // not an string On the other hand, IEnumerable<T> is a read-only interface. The T … Read more

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

Is there a generic Task.WaitAll?

A generic method of Task.WaitAll would imply that all Tasks would have to return the same type which would be extremely limited usefulness. Writting something like that could be done manually (see Bas Brekelmans answer), but this wont allow ContinueWith or cancellation without alot of work. A simple solution if you aren’t using the array … Read more

Why is Task not co-variant?

According to someone who may be in the know… The justification is that the advantage of covariance is outweighed by the disadvantage of clutter (i.e. everyone would have to make a decision about whether to use Task or ITask in every single place in their code). It sounds to me like there is not a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)