Here's a quick reference for Generic co- and contravariance is new in C# 4.
If T appears only as an output, it’s safe to pass .List<TDerived> for List<T>. (Co-variance).
If T appears only as an input, it’s safe to pass List<TBase> for List<T>. (Contra-variance).
No comments:
Post a Comment