The difference exists in C # 4.0 for .NET 4), but is limited to interfaces and the use of in/ out(oh and arrays of reference types). For example, to make a covariant sequence:
class DalBase<T> : IEnumerable<T> where T: ReplicatedBaseType
{
public IEnumerator<T> GetEnumerator() {throw new NotImplementedException();}
IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); }
}
class DocumentTemplate
{
IEnumerable<ReplicatedBaseType> BaseCollection;
DocumentTemplate()
{
BaseCollection = new DalBase<NewType>();
}
}
But other than that ... no. Stick to either non-generic lists ( IList) or use the expected list type.
source
share