I'm trying to build a class that will hold a row of data from a CSV file along with its header information. Then outside the class I am making a List<> of elements of this class. However I am getting this error which completely worthless, "DynamicCSV does not contain a constructor that takes 1 arguments." Fact is it does in fact contain a constructor with 1 argument.
class DynamicCSV : DynamicObject
{
public List<string> columnHeaders;
public List<string> rowData;
/* Constructor with 1 argument */
DynamicCSV(List<string> headers)
{
columnHeaders = new List<string>();
dynamic rowData = new List<string>();
columnHeaders = headers;
}
}
/* code that calls the constructor */
while (!streamReader.EndOfStream)
{
List<string> headers = new List<string>();
List<string> dataRow = new List<string>();
List<DynamicCSV> dataRows = new List<DynamicCSV>();
if (true == isHeaderRow)
{
currentRow = streamReader.ReadLine();
headers.AddRange(currentRow.Split(','));
dataRows.Add(new DynamicCSV(headers)); // here is the error
isHeaderRow = false;
}
else
{
currentRow = streamReader.ReadLine();
dataRow.AddRange(currentRow.Split(','));
}
}