Hi,
I am trying to develop a Silverlight 4 application using C# 4.0. I have a case like this:
public class Foo<T> : IEnumerable<T>
{
....
}
Elsewhere:
public class MyBaseType : MyInterface
{
...
}
And the usage where I am having problems:
Foo<MyBaseType> aBunchOfStuff = new Foo<MyBaseType>();
Foo<MyInterface> moreGeneralStuff = myListOFStuff;
Now I believe this was impossible in C# 3.0 because generic type were "Invariant". However I thought this was possible in C# 4.0 through the new covariance for generics technology?
As I understand it, in C# 4.0 a lot of common interfaces (like IEnumerable) have been modified to support variance. In this case does my Foo
class need to anything special in order to become covariant?
And is covariance supported in Silverlight 4 (RC) ?