I have a FileRecord class with the following definition:
public class FileRecord
{
public IList<IDataRecord> DataRecords { get; set; }
public IList<ImageFile> Images { get; set; }
public string IndexFileName { get; set; }
public string IndexFilePath { get; set; }
}
please note that datarecords is a IList of an interface type.
I then have a method that creates a file record for each type of datarecords we have:
fileRecord = new FileRecord
{
DataRecords = CsvFile.Read<VallDataData>(Path.GetFullPath(indexFile.FullName)).Where(x => x.GiftAidValidity == "Y").ToList<IDataRecord>()
};
if I remove the implicit casting on the ToList<IDataRecord>() to ToList()
I get this error message:
Error CS0266 Cannot implicitly convert type 'System.Collections.Generic.List<VallDataData>' to 'System.Collections.Generic.IList<IDataRecord>'. An explicit conversion exists (are you missing a cast?)
even though VallDataData implements IDataRecord
why is this?
Thanks.