>I don't think my design is very good, if I spell it out what I'm trying to do you might have a better way of achieving what I'm struggling with, I'm pulling data from several different Excel worksheets using NPOI and then serialising them to a csv file using the class you pointed out a week or so back, all this is working well but I want to tidy it up. At present there are only three different types of imports but I'm sure this will change in the future - so basically I need to build a List for the serialiser of one of three types
Not sure I understand the problem. If all three classes implement ITarriffDataImport why can't you use a non-generic version of XlToList as suggested in my update ? Simply:
public class XlToList
{
public List<ITarriffDataImport> Data { get; set; }
}
and use the linq Cast to populate the Data field. Assuming TDI1 implements ITarriffDataImport:
var theList = new List<TDI1>();
var xlListClass = new XlToList();
xlListClass.Data = theList.Cast<ITarriffDataImport>().ToList();
UPDATE: Actually, if you make the Data field IEnumerable rather than List you don't need to cast ........