I have two methods that return list of EmployeeCsv and CardCsv.
public class EmployeeCsv
{
public string EmployeeId { get; set; }
public string EmployeeName { get; set; }
}
public class CardCsv
{
public string MaxCharge { get; set; }
public string MaxDiscount { get; set; }
}
public List<EmployeeCsv> GetEmployeeList() {} // returns list of EmployeeCsv
public List<CardCsv> GetCardList() {} // returns list of CardCsv
I wanted to declare one type list for those two methods. So I changed them like below
public interface ITest {}
public class EmployeeCsv : ITest
{
public string EmployeeId { get; set; }
public string EmployeeName { get; set; }
}
public class CardCsv : ITest
{
public string MaxCharge { get; set; }
public string MaxDiscount { get; set; }
}
public List<ITest> GetEmployeeList() {}
public List<ITest> GetCardList() {}
Main:
void main()
{
var records = new List<ITest>();
records = GetEmployeeList();
using (var writer = new StreamWriter(fileName))
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
{
csv.Configuration.ShouldQuote = (field, context) => true;
csv.WriteRecords(records); // error here
}
}
I get an error on saving after adding interface to those two classes. How can I fix this?