In C # 3.0 / .NET 3.5, IEnumerable<T> not covariant. However, this is likely to work fine in C # 4.0 / .NET 4.0.
Now you can (in .NET 3.5) use:
baseList.AddRange(derivedList.Cast<BaseItem>());
(note that you need " using System.Linq; " at the top of the file)
Before that ... perhaps the easiest way is to just loop:
foreach(BaseItem item in derivedList) {baseList.Add(item);}
source share