2

I have csv file that I read and store in IEnumerable data_values. The only problem is that when I want to read it with MessageBox.Show() then it throws ArgumentNullException was unhandled. I tried to do it like if(data_values != null) but it doesn't work. I tried many many solutions but none works. All I want to do is to assign data from date_values to for example temperatures_values and show it. This is what it looks like:

class CSVdata
{
    public List<data> data_var = new List<data>();
    public IEnumerable<data> data_values;
    public CSVdata()
    {
         CsvFileDescription file_description = new CsvFileDescription { 
            SeparatorChar = ';',
            FirstLineHasColumnNames = true,
            EnforceCsvColumnAttribute = true
            };

        CsvContext cc = new CsvContext();
        data_values = cc.Read<data>("C:/Users/GreenScreen/Desktop/Transbud_pomiary_csvFile.csv", file_description);
        data_var = data_values.ToList();
    }
}

And I want to show it with:

    private void button_ReadData_Click(object sender, EventArgs e)
    {
        CSVdata csvData = new CSVdata();
        MessageBox.Show(csvData.data_var[5].ToString());
    }
Maverick
  • 1,396
  • 5
  • 22
  • 42
  • Have you overridden the `ToString()` method in the `data` class? If so, please post it as that could be the source of the error. – Glorfindel Jul 25 '15 at 09:46

0 Answers0