To indicate that the generic parameter type of an interface or delegate is covariant in T , you need to specify the out keyword.
However, this is currently not possible for classes. I suggest creating an interface with a covariant typical type parameter, and let your class implement it.
As for support for covariance in Silverlight 4: it was not supported in beta, I needed to check if they implemented it in a candidate for release. Edit: Apparently this is so.
Edit2: There can be some confusion as to whether SL4 supports joint and contravariance for interfaces and delegates due to the fact that some of the types in BCL do not have corresponding type modifiers ( IEnumerable<T> , Action<T> , Func<T> , ...).
Silverlight 5 solves these problems: http://10rem.net/blog/2011/09/04/the-big-list-of-whats-new-or-improved-in-silverlight-5
However, the SL4 compiler does support in and out modifiers. The following compiles and works as expected:
interface IFoo<out T> { T Bar { get; } } interface IBar<in T> { void Add(T value); } delegate void ContravariantAction<in T>(T value); delegate T CovariantFunc<out T>();
source share