I have the following inheritance:
internal abstract class TeraRow{}
internal class xRow : TeraRow {} // xRow is a child of TeraRow
public IEnumerable
If you need the casted list to perform like the original reference (setting an item at an index also sets the item in the original collection, you can create a wrapper class that implements IList
public class UpCastList : IList
where FromType : ToType
public class DownCastList
where ToType : FromType
The other possibility is delegating the conversion:
public class CastList : IList
{
public CastList(IList source, Func converter) { ... }
}
Edit: if you only need an IEnumerable