I have tried looking at other peoples questions to find a solution however just cannot understand what/why this is happening. If someone can take a look at this code and explain why this is causing it may give me a better understanding
private animalClass[] fileToAnimalArray(String fileName)
{
// read the number of lines in the file and declare animal array with exact number needed
int lineCount = File.ReadLines(fileName).Count();
animalClass[] animalArray = new animalClass[lineCount];
//declare temp variables to hold a single read out from the file and a string array to hold the split up string
String line;
String[] lineArray = new String[10];
// open up file in prepartion to read file
StreamReader file = new StreamReader(fileName);
// start loop in order to extract each line of the file
for (int i = 0; i < lineCount; i++)
{
// read line and spllit it
line = file.ReadLine();
lineArray = line.Split(',');
string temp = lineArray[0];
// assign split string into each property of the animal array casting if needed.
animalArray[i].aClass = lineArray[0]; // *error thrown here*
animalArray[i].aOrder = lineArray[1];
animalArray[i].aFamily = lineArray[2];
animalArray[i].aGenus = lineArray[3];
animalArray[i].aName = lineArray[4];
animalArray[i].aLength = Convert.ToDouble(lineArray[5]);
animalArray[i].aWeight = Convert.ToDouble(lineArray[6]);
animalArray[i].extState = lineArray[7];
animalArray[i].recordCreationDate = Convert.ToDateTime(lineArray[8]);
animalArray[i].recordLastEdit = Convert.ToDateTime(lineArray[9]);
}
// close the file
file.Close();
// return the array
return animalArray;
}
many thanks, Cameron