This code here does not work and throws the exception 'object reference not set to an instance of an object'
I'm not sure why this is happening as I'm pretty sure I set the value of 'line'
public void LoadCasesDataFile(string filename)
{
int countryCount = 0;
int dateCount = 0;
using (StreamReader file = new StreamReader(filename))
{
while (!file.EndOfStream)
{
if (countryCount < 206)
{
while (dateCount < 110)
{
var line = file.ReadLine();
var values = line.Split(',');
if (values[0] == CountriesArray[countryCount].GetName())
{
DateTime testDate = Convert.ToDateTime(values[1]);
CountriesArray[countryCount].AddDate(Convert.ToDateTime(values[1]), Convert.ToInt32(values[2]), Convert.ToInt32(values[3]), dateCount);
dateCount++;
}
}
countryCount++;
}
}
}
}